View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
carmjo005 carmjo005 is offline
external usenet poster
 
Posts: 12
Default Selection multiple ranges with Cells property

How can I select multiple non-adjacent ranges using the Cells property.
I know that Range("A2:A7, F2:F7, J2:J7").Select works. However the number of
rows varies each time the macro is run. Also, although the number of rows may
vary each time the macro is run the number of rows in A, F, and J
respectively, remain equal with each run. I've tried the following

' I = last data row
Dim R1, R2, R3, MyMultipleRange As Range
Sheets("Scratch").Select
R1=Range(Cells(2, 1), Cells(I, 1))
R2=Range(Cells(2, 6), Cells(I, 6))
R3=Range(Cells(2, 10), Cells(I, 10))
Set myMultipleRange = Union(R1, R2 R3)
myMultipleRange.Select

with no success. I plan to use the selected range in a ListBox and have been
able to do this if I make the three columns of data adjacent. But I thought
I'd ask for expert help first. Can it be done without making the columns
adjacent? Or, is there a better way?
Thanks