Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Selecting a range using a column number reference

I know this code isn't correct, but it's what I've got so far.

Range((c + 2) & "2").Select

"c" is a variable in which was set in previous code using:
c = cell.Column

I'm trying to write the code so that it will select a range that will match
the column set by the variable (in this case is column 142 + 2, and row 2.
I believe this is somewhere around EL2. How can I change the code so that
it will select the range using the column number reference instead of the
letter reference?

Thanks,
Paul


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Selecting a range using a column number reference

replace with 142+2 your variable in the formula

Cells(2, 142 + 2).Select

--


Gary


"PCLIVE" wrote in message
...
I know this code isn't correct, but it's what I've got so far.

Range((c + 2) & "2").Select

"c" is a variable in which was set in previous code using:
c = cell.Column

I'm trying to write the code so that it will select a range that will
match the column set by the variable (in this case is column 142 + 2, and
row 2. I believe this is somewhere around EL2. How can I change the code
so that it will select the range using the column number reference instead
of the letter reference?

Thanks,
Paul



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Selecting a range using a column number reference

That's what I was looking for. I was close while I was waiting for a reply.
Another quesiton.

How could I select a range of cells the same way.
I've tried this which didn't work.

Range(Cells(2, c + 3)) & ":" & (Cells(50, c + 4)).Select

Thanks again,
Paul

"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
replace with 142+2 your variable in the formula

Cells(2, 142 + 2).Select

--


Gary


"PCLIVE" wrote in message
...
I know this code isn't correct, but it's what I've got so far.

Range((c + 2) & "2").Select

"c" is a variable in which was set in previous code using:
c = cell.Column

I'm trying to write the code so that it will select a range that will
match the column set by the variable (in this case is column 142 + 2, and
row 2. I believe this is somewhere around EL2. How can I change the code
so that it will select the range using the column number reference
instead of the letter reference?

Thanks,
Paul





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Selecting a range using a column number reference

like this

Range(Cells(2, c + 3), Cells(50, c + 4)).Select

--


Gary


"PCLIVE" wrote in message
...
That's what I was looking for. I was close while I was waiting for a
reply.
Another quesiton.

How could I select a range of cells the same way.
I've tried this which didn't work.

Range(Cells(2, c + 3)) & ":" & (Cells(50, c + 4)).Select

Thanks again,
Paul

"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
replace with 142+2 your variable in the formula

Cells(2, 142 + 2).Select

--


Gary


"PCLIVE" wrote in message
...
I know this code isn't correct, but it's what I've got so far.

Range((c + 2) & "2").Select

"c" is a variable in which was set in previous code using:
c = cell.Column

I'm trying to write the code so that it will select a range that will
match the column set by the variable (in this case is column 142 + 2,
and row 2. I believe this is somewhere around EL2. How can I change the
code so that it will select the range using the column number reference
instead of the letter reference?

Thanks,
Paul







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Selecting a range using a column number reference

One more way:

Cells(2, c + 3).resize(49,2).select


PCLIVE wrote:

That's what I was looking for. I was close while I was waiting for a reply.
Another quesiton.

How could I select a range of cells the same way.
I've tried this which didn't work.

Range(Cells(2, c + 3)) & ":" & (Cells(50, c + 4)).Select

Thanks again,
Paul

"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
replace with 142+2 your variable in the formula

Cells(2, 142 + 2).Select

--


Gary


"PCLIVE" wrote in message
...
I know this code isn't correct, but it's what I've got so far.

Range((c + 2) & "2").Select

"c" is a variable in which was set in previous code using:
c = cell.Column

I'm trying to write the code so that it will select a range that will
match the column set by the variable (in this case is column 142 + 2, and
row 2. I believe this is somewhere around EL2. How can I change the code
so that it will select the range using the column number reference
instead of the letter reference?

Thanks,
Paul




--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Selecting a range using a column number reference

Thanks again Gary.
That did the trick.

Paul

"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
like this

Range(Cells(2, c + 3), Cells(50, c + 4)).Select

--


Gary


"PCLIVE" wrote in message
...
That's what I was looking for. I was close while I was waiting for a
reply.
Another quesiton.

How could I select a range of cells the same way.
I've tried this which didn't work.

Range(Cells(2, c + 3)) & ":" & (Cells(50, c + 4)).Select

Thanks again,
Paul

"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
replace with 142+2 your variable in the formula

Cells(2, 142 + 2).Select

--


Gary


"PCLIVE" wrote in message
...
I know this code isn't correct, but it's what I've got so far.

Range((c + 2) & "2").Select

"c" is a variable in which was set in previous code using:
c = cell.Column

I'm trying to write the code so that it will select a range that will
match the column set by the variable (in this case is column 142 + 2,
and row 2. I believe this is somewhere around EL2. How can I change
the code so that it will select the range using the column number
reference instead of the letter reference?

Thanks,
Paul









  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Selecting a range using a column number reference

Dave,

Thanks for the reply. I've already gotten code that works. However, I was
curious about your suggestion.

In your code, what does "resize(49,2)" do?

Thanks,
Paul

"Dave Peterson" wrote in message
...
One more way:

Cells(2, c + 3).resize(49,2).select


PCLIVE wrote:

That's what I was looking for. I was close while I was waiting for a
reply.
Another quesiton.

How could I select a range of cells the same way.
I've tried this which didn't work.

Range(Cells(2, c + 3)) & ":" & (Cells(50, c + 4)).Select

Thanks again,
Paul

"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
replace with 142+2 your variable in the formula

Cells(2, 142 + 2).Select

--


Gary


"PCLIVE" wrote in message
...
I know this code isn't correct, but it's what I've got so far.

Range((c + 2) & "2").Select

"c" is a variable in which was set in previous code using:
c = cell.Column

I'm trying to write the code so that it will select a range that will
match the column set by the variable (in this case is column 142 + 2,
and
row 2. I believe this is somewhere around EL2. How can I change the
code
so that it will select the range using the column number reference
instead of the letter reference?

Thanks,
Paul




--

Dave Peterson



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Selecting a range using a column number reference

It takes the original range and changes the size of it.

..resize(x,y)
says to make the new range x number of rows deep by y numbers of columns wide.

VBA's help has more information if you want it.

ps. There's also a .offset(x,y) property that can be used to "Move" to a
different range based on the original range and those x,y values.

PCLIVE wrote:

Dave,

Thanks for the reply. I've already gotten code that works. However, I was
curious about your suggestion.

In your code, what does "resize(49,2)" do?

Thanks,
Paul

"Dave Peterson" wrote in message
...
One more way:

Cells(2, c + 3).resize(49,2).select


PCLIVE wrote:

That's what I was looking for. I was close while I was waiting for a
reply.
Another quesiton.

How could I select a range of cells the same way.
I've tried this which didn't work.

Range(Cells(2, c + 3)) & ":" & (Cells(50, c + 4)).Select

Thanks again,
Paul

"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
replace with 142+2 your variable in the formula

Cells(2, 142 + 2).Select

--


Gary


"PCLIVE" wrote in message
...
I know this code isn't correct, but it's what I've got so far.

Range((c + 2) & "2").Select

"c" is a variable in which was set in previous code using:
c = cell.Column

I'm trying to write the code so that it will select a range that will
match the column set by the variable (in this case is column 142 + 2,
and
row 2. I believe this is somewhere around EL2. How can I change the
code
so that it will select the range using the column number reference
instead of the letter reference?

Thanks,
Paul




--

Dave Peterson


--

Dave Peterson
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
I lost the highlight color when selecting a range, column or row. Markcappy Excel Discussion (Misc queries) 0 January 21st 09 07:56 PM
Selecting the correct number from a range of cells pajones via OfficeKB.com Excel Worksheet Functions 4 September 18th 06 04:04 PM
after selecting 50 rows of a column i can't reference the cells in the rows Bob Salzer New Users to Excel 2 July 21st 06 10:29 PM
Selecting specific row/column from a named range [email protected] Excel Worksheet Functions 2 November 16th 05 09:24 PM
reference to column (not known) and certain row number gaba Excel Programming 3 November 15th 04 01:34 PM


All times are GMT +1. The time now is 11:36 PM.

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

About Us

"It's about Microsoft Excel"