Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting a Range with a Variable in VB
Hello All,
I am trying to update a macro. I know that I can select an individual cell using a variable by using the Cells property. I simply insert the variable into the parameter as an index number for a row or column. However, if I want to work with a range of cells, there is no way to pass a variable into the Range property. I'm sure this is a basic quesiton for you programmers out there. Can someone please drop me a dime? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting a Range with a Variable in VB
Not 100% sure what you are looking for but perhaps this is close...
range(Cells(1,1), cells(5,5)).select -- HTH... Jim Thomlinson "ClinicITguy1" wrote: Hello All, I am trying to update a macro. I know that I can select an individual cell using a variable by using the Cells property. I simply insert the variable into the parameter as an index number for a row or column. However, if I want to work with a range of cells, there is no way to pass a variable into the Range property. I'm sure this is a basic quesiton for you programmers out there. Can someone please drop me a dime? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting a Range with a Variable in VB
Thanks.
I think I just had problems understanding how the parameters in the range property functioned. The help documentation seemed to separate the parameters with a colon, but then suggested that multiple sections be divided by a comma. That was confusing. The following table illustrates some A1-style references using the Range property. Reference Meaning Range("A1") Cell A1 Range("A1:B5") Cells A1 through B5 Range("C5:D9,G9:H16") A multiple-area selection Range("A:A") Column A Range("1:1") Row 1 Range("A:C") Columns A through C Range("1:5") Rows 1 through 5 Range("1:1,3:3,8:8") Rows 1, 3, and 8 Range("A:A,C:C,F:F") Columns A, C, and F "Jim Thomlinson" wrote: Not 100% sure what you are looking for but perhaps this is close... range(Cells(1,1), cells(5,5)).select -- HTH... Jim Thomlinson "ClinicITguy1" wrote: Hello All, I am trying to update a macro. I know that I can select an individual cell using a variable by using the Cells property. I simply insert the variable into the parameter as an index number for a row or column. However, if I want to work with a range of cells, there is no way to pass a variable into the Range property. I'm sure this is a basic quesiton for you programmers out there. Can someone please drop me a dime? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Selecting a Range with a Variable in VB
Range takes up to 2 arguments. The first argument is mandatory and the second
is optional. If only the first argument is specified then the range is made up of whatever is specified in the first argument. If the optional second argument is included the the range bounded by the upper left most cell and lower right most cell of the 2 ranges will make a rectangular range of that size. -- HTH... Jim Thomlinson "ClinicITguy1" wrote: Thanks. I think I just had problems understanding how the parameters in the range property functioned. The help documentation seemed to separate the parameters with a colon, but then suggested that multiple sections be divided by a comma. That was confusing. The following table illustrates some A1-style references using the Range property. Reference Meaning Range("A1") Cell A1 Range("A1:B5") Cells A1 through B5 Range("C5:D9,G9:H16") A multiple-area selection Range("A:A") Column A Range("1:1") Row 1 Range("A:C") Columns A through C Range("1:5") Rows 1 through 5 Range("1:1,3:3,8:8") Rows 1, 3, and 8 Range("A:A,C:C,F:F") Columns A, C, and F "Jim Thomlinson" wrote: Not 100% sure what you are looking for but perhaps this is close... range(Cells(1,1), cells(5,5)).select -- HTH... Jim Thomlinson "ClinicITguy1" wrote: Hello All, I am trying to update a macro. I know that I can select an individual cell using a variable by using the Cells property. I simply insert the variable into the parameter as an index number for a row or column. However, if I want to work with a range of cells, there is no way to pass a variable into the Range property. I'm sure this is a basic quesiton for you programmers out there. Can someone please drop me a dime? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Selecting a Range using a variable | Excel Programming | |||
selecting a variable row range | Excel Programming | |||
Selecting a variable range | Excel Programming | |||
Selecting a variable Range | Excel Programming | |||
Selecting a Range Using a Variable | Excel Programming |