ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selecting a range using a column number reference (https://www.excelbanter.com/excel-programming/342747-selecting-range-using-column-number-reference.html)

PCLIVE

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



Gary Keramidas

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




PCLIVE

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






Gary Keramidas

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








Dave Peterson

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

PCLIVE

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










PCLIVE

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




Dave Peterson

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


All times are GMT +1. The time now is 10:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com