Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Variables in a Range statement

How can I insert variables in a range statement. For instance: I
have looked down column j for a particular value and have found it in
row m. If I copy everything from the top (A1) up thru row m I can use:

Sheets("Sheet1").Range("a1:j" & m).Copy ActiveSheet.Range("A4")

where I can append the row range m to 'j'. But in general, how can
I use variables for the arguements in the Range statement.
thanks
chuck
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Variables in a Range statement

Dim i as long, m as long
Dim sA as string, sB as String
Dim sStr as String
i = 1
m = 20
sStr = "A" & i & ":" & "J" & m

Range(sStr).Select

sA = "AA"
sB = "AK"
sStr = sA & i & ":" & sB & m
Range(sStr).Select

Generally if you are going to use variables for row and column locations, it
is easier to use Cells
Dim rw as long, rw1 as long, col as long, col1 as long
rw = 1
col = 5
rw1 = 20
col1 = 8
Range(Cells(rw,col),Cells(rw1,col1)).Select

--
Regards,
Tom Ogilvy


"ChuckM" wrote in message
m...
How can I insert variables in a range statement. For instance: I
have looked down column j for a particular value and have found it in
row m. If I copy everything from the top (A1) up thru row m I can use:

Sheets("Sheet1").Range("a1:j" & m).Copy ActiveSheet.Range("A4")

where I can append the row range m to 'j'. But in general, how can
I use variables for the arguements in the Range statement.
thanks
chuck



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
IF Statement with two variables RoadKill Excel Worksheet Functions 9 April 4th 23 12:47 PM
how do i if statement for 3 variables wheefus Excel Worksheet Functions 7 December 17th 07 07:26 PM
Conditional Statement with many variables Krista Excel Discussion (Misc queries) 3 May 12th 06 10:58 PM
Too many variables for an if than statement? repke New Users to Excel 3 May 2nd 06 05:01 PM
Using variables as first and last cells in range statement Tom from Ga Excel Worksheet Functions 2 February 6th 06 09:08 PM


All times are GMT +1. The time now is 02:33 PM.

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

About Us

"It's about Microsoft Excel"