Copy and Paste - Specific cells and range

jamescooper

Well-known Member
Joined
Sep 8, 2014
Messages
834
Trying to copy a range to a specific range referencing cells, anyone know why this will work please?

Code:
Range("AG2:BC" & Range("BI1")).Copy _
Destination:=Sheets("Data").Range("D" & .Range("AD3"), .Range("Z" & .Range("AD4")))
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Do you have a With statement that you aren't showing? and what are in cells AD3 and AD4?
 
Upvote 0
I am not sure what you are trying to do but this code does at least compile and should show you what you need to do to fix your code
Code:
ii = ActiveSheet.Range("B1:B1")
With Worksheets("sheet3")


id3 = .Range("AD3")
id4 = .Range("AD4")


Range("A2:B" & ii).Copy Destination:=Sheets("Data").Range("D" & id3): .Range ("Z" & id4)
End With
 
Upvote 0
Do you have a With statement that you aren't showing? and what are in cells AD3 and AD4?

No with statement

Its in a Worksheet_Calculate, AD3 is 9 and AD4 is 16 as they are variable.
Code:
Private Sub Worksheet_Calculate()
Range("AG2:BC" & Range("BI1")).Copy _
Destination:=Sheets("Data").Range("D" & .Range("AD3"), .Range("Z" & .Range("AD4")))
End Sub
 
Upvote 0
Well the way you have written it .Range("AD3") and .Range("Z" & .Range("AD4") would need a With statement to go with the period/fullstop in front of Range.
What sheet are the 2 cells on?
 
Upvote 0
Then either
Code:
Private Sub Worksheet_Calculate()
    With Sheets("Data")
        Range("AG2:BC" & Range("BI1")).Copy _
                Destination:=.Range("D" & .Range("AD3"), .Range("Z" & .Range("AD4")))
    End With
End Sub
or
Code:
Private Sub Worksheet_Calculate()
    Range("AG2:BC" & Range("BI1")).Copy _
            Destination:=Sheets("Data").Range("D" & Sheets("Data").Range("AD3"), Sheets("Data").Range("Z" & Sheets("Data").Range("AD4")))
End Sub

and if you want you can remove the
Code:
Destination:=
if you want.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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