ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Use variable to reference a range? (https://www.excelbanter.com/excel-programming/380919-use-variable-reference-range.html)

RITCHI

Use variable to reference a range?
 
Hi

Is it possible to use a variable as part of a range reference?
In the example below I want to change the value 6000 to a different
value that changes from time to time. Can I substitute 6000 for x, y
z etc.
Range("d4:d6000").Value = 1

Any help would be gratefully received.

Thanks

Ritchi


RITCHI

Use variable to reference a range?
 
Thanks Tom

Just the job.

Regards
Ritchi


Tom Ogilvy wrote:

Dim x as Long
x = 6000
Range("D4:D" & x).Value = 1


y = 4
z = 4
x = 6000
Cells(y,z).Resize(x,1).Value = 1

Cells(row, column)

--
Regards,
Tom Ogilvy


--
Regards,
Tom Ogilvy


"RITCHI" wrote:

Hi

Is it possible to use a variable as part of a range reference?
In the example below I want to change the value 6000 to a different
value that changes from time to time. Can I substitute 6000 for x, y
z etc.
Range("d4:d6000").Value = 1

Any help would be gratefully received.

Thanks

Ritchi





All times are GMT +1. The time now is 04:41 AM.

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