chipsworld
Board Regular
- Joined
- May 23, 2019
- Messages
- 164
- Office Version
- 365
Hello all,
Need your help. I am unsure why the below is not working. All I am trying to accomplish is to lookup a value in column A, find that same value in Column A on a different sheet, and copy the data from the first sheet in Column G:O to the same G:O range in the second sheet...
When I get to the Copy range line, I get the "Run time error 1004: "Application-defined or object-defined error" on the "COPY line of code
None of the sheets are protected and no merged cells...
Here is the code and thanks in advance for your help...
Need your help. I am unsure why the below is not working. All I am trying to accomplish is to lookup a value in column A, find that same value in Column A on a different sheet, and copy the data from the first sheet in Column G:O to the same G:O range in the second sheet...
When I get to the Copy range line, I get the "Run time error 1004: "Application-defined or object-defined error" on the "COPY line of code
None of the sheets are protected and no merged cells...
Here is the code and thanks in advance for your help...
VBA Code:
Private Sub CommandButton1_Click()
Dim rw As Double
Dim rw2 As Double
Dim lstrow As Double
Dim ws As Worksheet
Dim lkup As String
Set ws = Sheets("Lice Tracker")
With ws
lstrow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
With Sheets("current census")
For rw = 2 To lstrow
lkup = .Cells(rw, "A")
Set fnd = .Range("A:A").Find(lkup, LookIn:=xlValues, LookAt:=xlPart, SearchDirection:=xlPrevious)
If Not fnd Is Nothing Then
rw2 = fnd.Row
[B][COLOR=rgb(226, 80, 65)]Worksheets("Lice Tracker").Range(rw, "G:O").Copy[/COLOR][/B] Destination:=Worksheets("current census").Cells(rw2, "G:O")
End If
Next rw
End With
End Sub
Last edited: