Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using variables in the Range command
Usually the Range method looks like:
Range("A1:C50") In my case, the first and last column are variables. How can I still use the Range method? I need to find a command to define my range like: dim rgRange as range rgRange = sheetname.range( (row i, column j): (row m, column n) ) any help? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using variables in the Range command
Sub test()
Dim Row1 As Long Dim Col1 As Long Dim Row2 As Long Dim Col2 As Long Dim rngRange As Range Set rngRange = _ Sheets(1).Range(Cells(Row1, Col1), _ Cells(Row2, Col2)) End Sub RBS "Chi Man Wong" wrote in message om... Usually the Range method looks like: Range("A1:C50") In my case, the first and last column are variables. How can I still use the Range method? I need to find a command to define my range like: dim rgRange as range rgRange = sheetname.range( (row i, column j): (row m, column n) ) any help? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using variables in the Range command
A minor modification of RBS's solution--just in case the activesheet wasn't
sheets(1): Sub test() Dim Row1 As Long Dim Col1 As Long Dim Row2 As Long Dim Col2 As Long Dim rngRange As Range col1 = 3 row1 = 1 col2 = 5 row2 = 7 with sheets(1) Set rngRange = .Range(.Cells(Row1, Col1), .Cells(Row2, Col2)) end with End Sub Note the extra dots with the .cells(). Chi Man Wong wrote: Usually the Range method looks like: Range("A1:C50") In my case, the first and last column are variables. How can I still use the Range method? I need to find a command to define my range like: dim rgRange as range rgRange = sheetname.range( (row i, column j): (row m, column n) ) any help? -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Range of variables with the 'floor' command included | Excel Worksheet Functions | |||
find command using variables | Excel Programming | |||
Input Command with Mainframe file and multiple variables | Excel Programming | |||
Range Variables | Excel Programming | |||
Variables in command lines | Excel Programming |