Should I be defining ranges differently?

davidam

Active Member
Joined
May 28, 2010
Messages
497
Office Version
  1. 2021
Platform
  1. Windows
Hello,
I am sure that there is no error in the following:
Code:
Dim Loc as Range
Set Loc = Range("worksheet!named_range").Find(What:=name)
Range(Loc.Offset(8001,0).Address  & ":" & Loc.Offset(9900,0).Address).Copy 
           mainSheet.Range("I201")
But the copy fails.

As a test I tried this:
Code:
mainSheet.Range("I201").Value = Loc.Offset(8001,0).Value
...and it works just fine. Which leads me to wonder if there is something inefficient about using the .Address method with a large range like this.
Thanks,
David
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
In what way does it fail?
Address is unnecessary there:

Code:
Dim Loc as Range
Set Loc = Range("worksheet!named_range").Find(What:=name)
Range(Loc.Offset(8001,0), Loc.Offset(9900,0)).Copy mainSheet.Range("I201")
 
Upvote 0
There is actually a series of ranges that are supposed to be copied and it simply posted the wrong data to one location and nothing to several others.
 
Upvote 0
Range(Loc.Offset(8001,0), Loc.Offset(9900,0)).Copy mainSheet.Range("I201")[/Code]
Or that line could written this way as well...

Code:
Loc.Offset(8001).Resize(1900).Copy mainSheet.Range("I201")
 
Upvote 0
Well that does seem to work. I have always used .Address, and with good results...probably got from this site! Thank you!
 
Upvote 0

Forum statistics

Threads
1,224,536
Messages
6,179,402
Members
452,909
Latest member
VickiS

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