Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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....
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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....



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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....

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default 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....

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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....



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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....

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
variable ranges gramps Excel Discussion (Misc queries) 4 February 4th 10 02:33 PM
Help with Variable Ranges! Nelson B. Excel Discussion (Misc queries) 1 August 21st 08 03:30 PM
Variable Ranges Erika Excel Worksheet Functions 1 November 30th 07 09:21 PM
variable reference ranges SC Excel Discussion (Misc queries) 2 September 14th 07 05:18 AM
Counting variable ranges and auto-summing variable ranges Father Guido[_5_] Excel Programming 2 March 29th 06 04:07 AM


All times are GMT +1. The time now is 06:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"