Kevin
asked on
Excel 2010 VBA code to select a range using existing Cell names
I want to copy a range from one workbook to another. The range that I want to copy will always have Cell(1,1) as the top left cell of the range. The location of the bottom right cell of the range will always be different, BUT it will always have the name "Last_Print_Cell" assigned to it.
How do I select and copy that range using VBA code?
Thanks!
How do I select and copy that range using VBA code?
Thanks!
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Sub CopyRange()
Dim newRange As Range
Set newRange = Worksheets(1).Range("A1:Last_Print_Cell")
newRange.Copy Destination:=Worksheets(2).Range("A1")
End Sub
Replace your sheet names and destination with what is appropriate for your workbook.Regards
You're welcome, girbeaud.
I don't expect any points but better would be
Range([A1],[Last_Print_Cel l]).Copy
Range([A1],[Last_Print_Cel
Your suggestion doesn't both select & copy the range though, Martin, as the question required :)
ASKER