Understanding Resize Method

  • Thread starter Thread starter ExcelMonkey
  • Start date Start date
E

ExcelMonkey

Why does using the Resize Method below return a cell address of $M$2? I
would have thought it would keep the addres the same. Also, why does it
absolute the range?

revrangeaddress = Range("M2:M13").Resize(1, 1).Address

Thanks

EM
 
Hi Excel Monkey..

The expression:

Range("M2:M13").Resize(1, 1).

will return a ramge, anchored in the firrst
cell of the host range, which is one one
row long and one column wide. i.e. a single
cell.
 
You have a couple of questions...
1. Why do you get $M$2 as your result. Resize can be used to expand or
contract a range. To that end it uses the upper left corner of the range as
the starting point and allows you to resize from that starting point. To get
the same size you would want...

with Range("M2:M13")
revrangeaddress = .Resize(.rows, .columns).Address
end with

2. Why absolute? Address always returns an absolute. If you need the $ signs
removed you can just use the substitute function.
 
You have a couple of questions...
1. Why do you get $M$2 as your result. Resize can be used to expand or
contract a range. To that end it uses the upper left corner of the range as
the starting point and allows you to resize from that starting point. To get
the same size you would want...

with Range("M2:M13")
revrangeaddress = .Resize(.rows, .columns).Address
end with

2. Why absolute? Address always returns an absolute. If you need the $ signs
removed you can just use the substitute function.

--
HTH...

Jim Thomlinson






- Show quoted text -

Nice explanation Jim. Only thing I will add is that you don't have to
use the Substitute function to get rid of the absolute references.
Just add False, False to the Address.
revrangeaddress = Range("M2:M13").Resize(1, 1).Address(False, False)
 
Thanks to all you responded.

EM

Norman Jones said:
Hi Excel Monkey..

The expression:

Range("M2:M13").Resize(1, 1).

will return a ramge, anchored in the firrst
cell of the host range, which is one one
row long and one column wide. i.e. a single
cell.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top