amrita17170909
Board Regular
- Joined
- Dec 11, 2019
- Messages
- 74
- Office Version
- 2019
- 2016
- 2013
- Platform
- Windows
I have a filtered table named "Table 3".
I have to match filtered values from column A of "Table 3" to column A of "Table 2" and if the condition is met copy the entire row to a new sheet named "Table 4"
I have tried the below code without any success
I have to match filtered values from column A of "Table 3" to column A of "Table 2" and if the condition is met copy the entire row to a new sheet named "Table 4"
I have tried the below code without any success
VBA Code:
Sub Copy_data_to_report()
Application.ScreenUpdating = False
lastRow = Worksheets("Table 3").Cells(Rows.Count, 1).End(xlUp).Row
nextRow = 2
For thisRow = 1 To lastRow
If Worksheets("Table 3").Cells(thisRow, 1).Value = Worksheets("Table 2").Cells(thisRow, 1).Value Then
Worksheets("Table 2").Rows(thisRow).Copy
Worksheets("Table 4").Activate
B = Worksheets("Table 4").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Table 4").Cells(B + 1, 1).Select
Worksheets("Table 4").Paste
nextRow = nextRow + 1
End If
Next
Application.CutCopyMode = False
End Sub
Last edited by a moderator: