ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Multiple Col. Selection (https://www.excelbanter.com/excel-programming/291664-multiple-col-selection.html)

David Fixemer

Multiple Col. Selection
 
Need a good way to select multiple columns using variables?

x=1 'column a
y=3 'column c

I would like to select column x and y but not column b?

David

Trevor Shuttleworth

Multiple Col. Selection
 
David

x=1 : y=3 : union(columns(x),columns(y)).Select

Regards

Trevor


"David Fixemer" wrote in message
...
Need a good way to select multiple columns using variables?

x=1 'column a
y=3 'column c

I would like to select column x and y but not column b?

David




Bob Phillips[_6_]

Multiple Col. Selection
 
Hi David,

Range(Cells(1, x), Cells(1, y)).EntireColumn.Select

is one way

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"David Fixemer" wrote in message
...
Need a good way to select multiple columns using variables?

x=1 'column a
y=3 'column c

I would like to select column x and y but not column b?

David




Frank Kabel

Multiple Col. Selection
 
Hi
one way: try
....
dim rng_1 as range
dim rng_2 as range
set rng_1 = cells(1,x).entirecolumn
set rng_2 = cells(1,y).entirecolumn
....



--
Regards
Frank Kabel
Frankfurt, Germany

David Fixemer wrote:
Need a good way to select multiple columns using variables?

x=1 'column a
y=3 'column c

I would like to select column x and y but not column b?

David


David Fixemer

Multiple Col. Selection
 
Bob,

I believe your method gets 1, 2, and 3?

David

Alan Beban[_4_]

Multiple Col. Selection
 
Was it tested before posting? It selects Columns A, B and C.

Alan Beban

Bob Phillips wrote:
Hi David,

Range(Cells(1, x), Cells(1, y)).EntireColumn.Select

is one way



Bob Phillips[_6_]

Multiple Col. Selection
 
David,

Yes it does, I missed the bit about column b. An adaptation of the method
(not necessarily the best way) is

Range(Cells(1, x).Address & "," & Cells(1,
y).Address).EntireColumn.Select

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"David Fixemer" wrote in message
...
Bob,

I believe your method gets 1, 2, and 3?

David





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

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