ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Strange offset fault (https://www.excelbanter.com/excel-programming/325269-strange-offset-fault.html)

ramcsir

Strange offset fault
 
Hallo, programmers

I have the following code:

Dim rng As String
Dim i As Integer

rng = "$A$1"
For i = 0 To 3
Debug.Print rng & " / " & Range(rng).offset(i, 1).Address
Next i

It produces the following results:

$A$1 / $C$1
$A$1 / $C$4
$A$1 / $C$5
$A$1 / $C$6

If you ask me it should produced the results

$A$1 / $B$1
$A$1 / $B$2
$A$1 / $B$3
$A$1 / $B$4

Can anybody tell me I am doing wrong.
Thanks in advance.

Ramcsir

Gixxer_J_97[_2_]

Strange offset fault
 
I just tried your code and it produced the results you expected

$A$1 / $B$1
$A$1 / $B$2
$A$1 / $B$3
$A$1 / $B$4

maybe there is something else going on

"ramcsir" wrote:

Hallo, programmers

I have the following code:

Dim rng As String
Dim i As Integer

rng = "$A$1"
For i = 0 To 3
Debug.Print rng & " / " & Range(rng).offset(i, 1).Address
Next i

It produces the following results:

$A$1 / $C$1
$A$1 / $C$4
$A$1 / $C$5
$A$1 / $C$6

If you ask me it should produced the results

$A$1 / $B$1
$A$1 / $B$2
$A$1 / $B$3
$A$1 / $B$4

Can anybody tell me I am doing wrong.
Thanks in advance.

Ramcsir


Bob Phillips[_6_]

Strange offset fault
 
I tried it and got the correct results also.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Gixxer_J_97" wrote in message
...
I just tried your code and it produced the results you expected

$A$1 / $B$1
$A$1 / $B$2
$A$1 / $B$3
$A$1 / $B$4

maybe there is something else going on

"ramcsir" wrote:

Hallo, programmers

I have the following code:

Dim rng As String
Dim i As Integer

rng = "$A$1"
For i = 0 To 3
Debug.Print rng & " / " & Range(rng).offset(i, 1).Address
Next i

It produces the following results:

$A$1 / $C$1
$A$1 / $C$4
$A$1 / $C$5
$A$1 / $C$6

If you ask me it should produced the results

$A$1 / $B$1
$A$1 / $B$2
$A$1 / $B$3
$A$1 / $B$4

Can anybody tell me I am doing wrong.
Thanks in advance.

Ramcsir





All times are GMT +1. The time now is 02:13 AM.

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