ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Offset by x (https://www.excelbanter.com/excel-programming/388576-offset-x.html)

[email protected]

Offset by x
 
Is there a way for the offset function to work with an undefined value
i.e. offset(x , 0) from an absolute cell.

for example at the end of a loop x = x+4 to increment the offset by 4
rows on each loop.

As I have a problem with many relative references so cannot use
activecell. the offset will always start from the same fixed position.


Jim Rech

Offset by x
 
Certainly you can use a variable in an offset:

Sub a()
Dim Counter As Integer
For Counter = 1 To 5
Range("A1").Offset(Counter).Value = Counter
Next
End Sub


--
Jim
wrote in message
oups.com...
| Is there a way for the offset function to work with an undefined value
| i.e. offset(x , 0) from an absolute cell.
|
| for example at the end of a loop x = x+4 to increment the offset by 4
| rows on each loop.
|
| As I have a problem with many relative references so cannot use
| activecell. the offset will always start from the same fixed position.
|



[email protected]

Offset by x
 
On 2 May, 18:29, "Jim Rech" wrote:
Certainly you can use a variable in an offset:

Sub a()
Dim Counter As Integer
For Counter = 1 To 5
Range("A1").Offset(Counter).Value = Counter
Next
End Sub

--
wrote in message

oups.com...
| Is there a way for the offset function to work with an undefined value
| i.e. offset(x , 0) from an absolute cell.
|
| for example at the end of a loop x = x+4 to increment the offset by 4
| rows on each loop.
|
| As I have a problem with many relative references so cannot use
| activecell. the offset will always start from the same fixed position.
|


thanks for the response. This really helped me out. I have used many
references to this now. Thanks again



All times are GMT +1. The time now is 12:23 AM.

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