Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
IF Statement with two variables | Excel Worksheet Functions | |||
how do i if statement for 3 variables | Excel Worksheet Functions | |||
Conditional Statement with many variables | Excel Discussion (Misc queries) | |||
Too many variables for an if than statement? | New Users to Excel | |||
Using variables as first and last cells in range statement | Excel Worksheet Functions |