copy range form one sheet to another

chipsworld

Board Regular
Joined
May 23, 2019
Messages
161
Office Version
  1. 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...

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:

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Try it like
VBA Code:
Worksheets("Lice Tracker").Range("G" & Rw).Resize(, 9).Copy Destination:=.Cells(rw2, "G")
 
Upvote 0
Solution
Thanks Fluff... I knew it would be something simple. However, I did learn something today!
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,523
Messages
6,120,031
Members
448,940
Latest member
mdusw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top