I am completely new to VBA and am trying to self teach how to write a basic macro to search the data on one work sheet, copy the desired data and paste it to the destination sheet. Here is the code I wrote, can someone explain in two year old terms why it is not working? Thank you
Sub Search_And_Copy()
'Number of last row that has data
'r = sheet("NAME OF SEARCH SHEET").Range("A" & rows.count).end(xlup).row
'Use specific cell for search
r = Sheets("NAME OF SEARCH SHEET").Cells(Rows.Count, DESIRED SEARCH COLUMN).End(xlUp).Row
For i = r To 1 Step 1
'get last row for destination sheet
Destination_Last_Row = Sheets("New").Cells(Rows.Count, 1).End(xlUp).Row
'copy data to new worksheet
Sheets("NAME OF SEARCH SHEET").Cells(i, 1).EntireRow.Copy Sheets("NAME OF DESTINATION SHEET").Cells(Destination_Last_Row + 1, 1)
'copy desired search data
If Sheets("NAME OF SEARCH SHEET").Cells(i, 4).Value = "SEARCH TERM" Then
'copy data to new worksheet
Sheets("NAME OF SEARCH SHEET").Cells(i, 1).EntireRow.Copy Sheets("NAME OF DESTINATION SHEET").Cells(Destination_Last_Row + 1, 1)
End If
Next i
End Sub
Bookmarks