Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default 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
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
Selecting a Range using a variable Chris Excel Programming 2 September 27th 06 09:40 PM
selecting a variable row range Dan Excel Programming 2 March 5th 05 12:03 PM
Selecting a variable range Dan Excel Programming 2 November 2nd 04 06:02 AM
Selecting a variable Range Brett[_6_] Excel Programming 1 September 9th 04 02:46 AM
Selecting a Range Using a Variable Bob J. Excel Programming 4 September 14th 03 09:24 PM


All times are GMT +1. The time now is 03:01 AM.

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"