Selecting Non-Consecutive Variables

C

Colin Vicary

Hello Experts!

I've written some code that prompts the user to indicate which colum
two type of data appear in.

I then want to select those two columns, which may not be next to eac
other, to copy to another sheet.

I've tried both versions below but neither work! Can anyone tell m
where I'm going wrong?

Columns(ISBNCol & "," & QtyCol).Select
Columns(ISBNCol, QtyCol).Select

Thanks

Coli
 
D

Dave Peterson

Union(Columns(ISBNCol), Columns(QtyCol)).Select

But you don't usually have to select a range to work with it.
 
B

Bernie Deitrick

Colin,

It depends on what ISBNCol and QtyCol are: numbers, ranges, strings?

If numbers (3, 5, for example) or strings ("C", "E", for example):

Union(Columns(ISBNCol), Columns(QtyCol)).Select

If ranges:

Union(ISBNCol.EntireColumn, QtyCol.EntireColumn).Select

HTH,
Bernie
MS Excel MVP
 
Top