ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   range.offset(0,1) is OK but range.offset(0,2) not (https://www.excelbanter.com/excel-programming/387845-range-offset-0-1-ok-but-range-offset-0-2-not.html)

clara

range.offset(0,1) is OK but range.offset(0,2) not
 
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
--
thank you so much for your help

Bernie Deitrick

range.offset(0,1) is OK but range.offset(0,2) not
 
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)

--
HTH,
Bernie
MS Excel MVP


"clara" wrote in message
...
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
--
thank you so much for your help





All times are GMT +1. The time now is 11:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com