Multiple Col. Selection

  • Thread starter Thread starter David Fixemer
  • Start date Start date
D

David Fixemer

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

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

Regards

Trevor
 
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)
 
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
....
 
Was it tested before posting? It selects Columns A, B and C.

Alan Beban
 
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top