ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Relative range syntax (https://www.excelbanter.com/excel-programming/426615-relative-range-syntax.html)

Bythsx-Addagio[_2_]

Relative range syntax
 
Hello,

I am running a loop which inserts a formula across cells in row 4 depending
on the value of g. I then would like to auto fill that formula down to the
below 14 rows.
ex. for column B.
Cells(4, g + 2).AutoFill Destination:=Range("B4:B18"), Type:=xlFillDefault

How can I write this so I can use the active column instead of the static
"B4:B14"

I was thinking of setting a range by:
set rng1 = range(R[1]C:R[14]C)

Then
Cells(4, g + 2).AutoFill Destination:=rng1, Type:=xlFillDefault

It doesn't work however. Any suggestions?

Thanks


Stefi

Relative range syntax
 
Try this (not tested):
Cells(4, g + 2).AutoFill Destination:=Range(Cells(4, g + 2), Cells(14, g
+ 2)), Type:=xlFillDefault
Regards,
Stefi

Bythsx-Addagio ezt *rta:

Hello,

I am running a loop which inserts a formula across cells in row 4 depending
on the value of g. I then would like to auto fill that formula down to the
below 14 rows.
ex. for column B.
Cells(4, g + 2).AutoFill Destination:=Range("B4:B18"), Type:=xlFillDefault

How can I write this so I can use the active column instead of the static
"B4:B14"

I was thinking of setting a range by:
set rng1 = range(R[1]C:R[14]C)

Then
Cells(4, g + 2).AutoFill Destination:=rng1, Type:=xlFillDefault

It doesn't work however. Any suggestions?

Thanks



All times are GMT +1. The time now is 05:43 AM.

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