Jump to content
Fórum Script Brasil
  • 0

Vba - copiar e colar linha inteira em outra planilha


gilson-bsb

Question

Pessoal, estou com uma dúvida simples mas não consigo desenvolve-la, o código abaixo seleciona uma linha que tem dados semelhantes na primeira coluna, gostaria apenas de pegar estes dados e copiar a linha inteira para outra planilha:

Public Sub Verifica()


Dim Col As Integer
Dim r As Long
Dim C As Range
Dim N As Long
Dim V As Variant
Dim Rng As Range


On Error GoTo EndMacro
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual


Col = ActiveCell.Column


If Selection.Rows.Count > 1 Then
Set Rng = Selection
Else
Set Rng = ActiveSheet.UsedRange.Rows
End If


N = 0
For r = Rng.Rows.Count To 1 Step -1
V = Rng.Cells(r, 1).Value
If Application.WorksheetFunction.CountIf(Rng.Columns(1), V) > 1 Then
Rng.Rows(r).Interior.ColorIndex = 36
Rng.Rows(r).Select
N = N + 1
End If



' Este é o trecho que estava tentando desenvolver para colar a linha selecionada em Rng.Row®


Selection.Copy
Sheets("Plan2").Select '
Chama a "Plan2"
'Range("A1").Select 'Seleciona a Linha 1 Da primeira Coluna
ActiveSheet.Paste 'Cola os valores selecionados da outra planilha



EndMacro:


Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic


End Sub
Exemplo da planilha, os dados repetidos da primeira coluna são selecionados de amarelo:
25332 JOAO 456325 45
25332 JOAO 456325 45
45333 MARIA 45689 35
48632 JOSE 45899 32
12356 CARLOS 32565 25
12356 CARLOS 32565 25

Abraço

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...