ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Select a range by column number (https://www.excelbanter.com/excel-programming/391027-select-range-column-number.html)

David Andrews

Select a range by column number
 
I need to select a range of cells knowing only the column index number (i)
So Range("C2:C12") needs to be Range("i2:i12").

I know there is the Cells command:
like Cells(5, i).Select
but this only selects one cell. I guess its a syntax problem for me.

Ideally i need to select a range with variable for row and column..any tips
?



Don Guillett

Select a range by column number
 
range(cells(2,i),cells(12,i)).select

However, you usually do NOT need to select to do what is needed and it is
better NOT to select.


--
Don Guillett
SalesAid Software

"David Andrews" wrote in message
news:_8yai.167$%M5.6@trndny02...
I need to select a range of cells knowing only the column index number (i)
So Range("C2:C12") needs to be Range("i2:i12").

I know there is the Cells command:
like Cells(5, i).Select
but this only selects one cell. I guess its a syntax problem for me.

Ideally i need to select a range with variable for row and column..any
tips
?




Bob Phillips

Select a range by column number
 
Cells(2, i).Resize(11).Select

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"David Andrews" wrote in message
news:_8yai.167$%M5.6@trndny02...
I need to select a range of cells knowing only the column index number (i)
So Range("C2:C12") needs to be Range("i2:i12").

I know there is the Cells command:
like Cells(5, i).Select
but this only selects one cell. I guess its a syntax problem for me.

Ideally i need to select a range with variable for row and column..any
tips
?






All times are GMT +1. The time now is 02:06 PM.

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