View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Trip Ives[_2_] Trip Ives[_2_] is offline
external usenet poster
 
Posts: 3
Default Using "Cells" to write "Range("A:A,H:H").Select"

Hello all,

I'm trying to select two non-contigious columns but do not know the
position of the second column because it changes depending on the
user's input. Thus, I need to calculate the position of the second
column. Thus, using "Cells" makes this operation much easier.

I know that the following do not work as they select all columns
between - I only want the two end columns:
Range(Cells(1, 1), Cells(1, 8)).EntireColumn.Select
Range(Cells(1, 1), Cells(1, 8).EntireColumn).Select
Range(Cells(1, 1).EntireColumn, Cells(1, 8).EntireColumn).Select

The only other option I can think of is to calculate the column number
and then run it through a big case-statement to derive the column name
and then piece together the standard range syntax using variables.
But that seems rediculous.

Any thoughts?

Thanks!

Trip