edsonpaula
New Member
- Joined
- Mar 22, 2021
- Messages
- 7
- Office Version
- 365
- Platform
- Windows
Hello, I have a worksheet with many rows and I need to copy and paste the entire row (paste value) to other sheets based on the value in column F.
I’m running the code below, but I’m not able to remove the blanc lines in the target sheet and paste values only, can someone help with that?
I’m running the code below, but I’m not able to remove the blanc lines in the target sheet and paste values only, can someone help with that?
VBA Code:
Sub macro1()
Dim c As Range
Dim j As Integer
Dim Source As Worksheet
Dim Target As Worksheet
Dim Target1 As Worksheet
Set Source = ActiveWorkbook.Worksheets("Sheet1")
Set Target = ActiveWorkbook.Worksheets("Sheet2")
Set Target1 = ActiveWorkbook.Worksheets("Sheet3")
j = 1
For Each c In Source.Range("F1:F" & Cells(Rows.Count, 1).End(xlUp).Row)
If c = "Ações" Then Source.Rows(c.Row).Copy Target.Rows(j)
If c = "Outros" Then Source.Rows(c.Row).Copy Target1.Rows(j)
j = j + 1
Next c
End Sub