When to use Offset versus Cells

John Kauffman

New Member
Joined
Oct 13, 2011
Messages
23
It seems Range().Offset() and Range().Cells() can acheive the same thing: a new range based on an original range.

I see both used in samples but can not figure out why one is selected over the other in each case.

Can anyone explain logic of which property to use in which cases?

Thanks.
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
In general, I use OFFSET() when I want to refer to a new range OUTSIDE of an already known/defined range, even if the range is a single cell.


I use the CELLS() method to define/select a specific subrange INSIDE of an already known/defined range.
 
Upvote 0
Jerry:
Sounds like a good rule of thumb (and easy to understand).
Is there a logic behind that or is it a convention for which it is easy to understand when maintaining code?
Thanks.

(Still reading the link supplied by Brian / MELDOC)
 
Upvote 0
What do you mean by "is there a logic"? My brief response was to outline my brief logic. Is there something else specific you're trying to figure out?
 
Upvote 0
Sorry if I irritated. I appreciate your help.

I was thinking of logic as something like
Offset() does not allow xxx, so best for outside a range
On the other hand, Cells() does not allow yyy, so best for inside a range

Maybe I am all wrong, but it seems both Offset() and Cell() are able to do the job of referencing another range relative to current range. Maybe there is not that functional overlap so my question is illogical.

My best guess is something along the lines that variable types that can be accepted by the Cell() or Offset() args are different and thus more useful inside/outside range.

Again, I appreciate your help.
 
Upvote 0
All of these refer to the same cell:

Code:
Range("myRange").Cells(1,2)
Range("myRange").Offset(0,1)
Range("myRange").Range("B1")

If I were using computed subscripts, I'd prefer one of the first two -- and if possible, the one that didn't require any additional arithmetic with the subscripts.
 
Upvote 0
Meldoc:

I read your ref page. I had found that, but read again on your recommendation. I got it - two differences. Encapsulated here for future searches.

Argument count base:
Offset(a,b) is 0
Cells(a,b) is 1

Resulting range if outer range is multicell:
Range(multicell).Offset() result is range of same shape as outer range
Range(multicell).Cells() always refers to a single cell
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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