![]() |
How to Variable Reference Row Ranges?
I'm trying to use variables to reference row ranges but don't know the syntax
or correct command. Instead of using a command like: Range("5:9") I'm trying to reference a number of row groups i.e. 5:9, 10:14, 15:19 and would like to be able to use a command like: Range("var1,var2") but this doesn't seem to work. Any ideas.... |
How to Variable Reference Row Ranges?
One way:
one way: Dim var1 As String Dim var2 As String var1 = "5:9" var2 = "10:14" Debug.Print Union(Range(var1), Range(var2)).Address another: Debug.Print Range(var1 & "," & var2).Address In article , VicWestVan wrote: I'm trying to use variables to reference row ranges but don't know the syntax or correct command. Instead of using a command like: Range("5:9") I'm trying to reference a number of row groups i.e. 5:9, 10:14, 15:19 and would like to be able to use a command like: Range("var1,var2") but this doesn't seem to work. Any ideas.... |
How to Variable Reference Row Ranges?
do you want to act on the entire row?
one way Range(Rows(3), Rows(5)).Select -- Gary "VicWestVan" wrote in message ... I'm trying to use variables to reference row ranges but don't know the syntax or correct command. Instead of using a command like: Range("5:9") I'm trying to reference a number of row groups i.e. 5:9, 10:14, 15:19 and would like to be able to use a command like: Range("var1,var2") but this doesn't seem to work. Any ideas.... |
How to Variable Reference Row Ranges?
Use syntax like this:
Range("4:10,16:21,26:30").Select Hope this helps, Hutch "VicWestVan" wrote: I'm trying to use variables to reference row ranges but don't know the syntax or correct command. Instead of using a command like: Range("5:9") I'm trying to reference a number of row groups i.e. 5:9, 10:14, 15:19 and would like to be able to use a command like: Range("var1,var2") but this doesn't seem to work. Any ideas.... |
How to Variable Reference Row Ranges?
Tom...
Thx for your comment. Actually not trying to reference the rows at the same time but conditional on other factors i.e. If EventA then Var1 = 10 var 2 = 14 else Var 1 = 20 var 2 = 24 End if Range("var1, var2") Any thoughts? "Tom Hutchins" wrote: Use syntax like this: Range("4:10,16:21,26:30").Select Hope this helps, Hutch "VicWestVan" wrote: I'm trying to use variables to reference row ranges but don't know the syntax or correct command. Instead of using a command like: Range("5:9") I'm trying to reference a number of row groups i.e. 5:9, 10:14, 15:19 and would like to be able to use a command like: Range("var1,var2") but this doesn't seem to work. Any ideas.... |
How to Variable Reference Row Ranges?
One way:
Range(var1 & ":" & var2) In article , VicWestVan wrote: Tom... Thx for your comment. Actually not trying to reference the rows at the same time but conditional on other factors i.e. If EventA then Var1 = 10 var 2 = 14 else Var 1 = 20 var 2 = 24 End if Range("var1, var2") Any thoughts? "Tom Hutchins" wrote: Use syntax like this: Range("4:10,16:21,26:30").Select Hope this helps, Hutch "VicWestVan" wrote: I'm trying to use variables to reference row ranges but don't know the syntax or correct command. Instead of using a command like: Range("5:9") I'm trying to reference a number of row groups i.e. 5:9, 10:14, 15:19 and would like to be able to use a command like: Range("var1,var2") but this doesn't seem to work. Any ideas.... |
All times are GMT +1. The time now is 09:55 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com