range.offset(0,1) is OK but range.offset(0,2) not

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I have four merged blocks in a row on a worksheet as follow:

BCDE FGH IJ K->T

I set rng to the first block's range whose addressi B1 then
I use rng.offset(0,1) to jump to the second block and I did it, but when I
want to continue with rng.offset(0,2) and rng.offset(0,3) , they did not jump
to third and fourth block, but to cell G1 and H1. I think I can reset the
starting range and use one rng.offset(0,1). Is there other hack way?


Clara
 
Clara,

Use successive offsets:

Dim rng As Range
Set rng = Range("B1")
MsgBox rng.Address
Set rng = rng.Offset(0, 1)
MsgBox rng.Address
Set rng = rng.Offset(0, 1)
MsgBox rng.Address
Set rng = rng.Offset(0, 1)
MsgBox rng.Address

OR

rng.Offset(0, 1).Offset(0, 1)

rng.Offset(0, 1).Offset(0, 1).Offset(0, 1)
 

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