PDA

View Full Version : Range is scattered in the sheet



circaa
08-02-2006, 11:22 AM
Hi

I'm looking for a way to set a range which is scattered in the sheet. For example : myrange = A2 an D2 and G2 and K2

I know I can set it with something like this

myrange = Range("A2,D2,G2,K2)")

But my sheet has many columns and the range varies depending on what the user needs. I'm looking for a way to do this with the cells method. Something that could maybe look like that..

myrange = range(cells(2,1);cells(2,4);cells(2,7);cells(2,10))

any ideas ?

Bob Phillips
08-02-2006, 11:34 AM
Dim myrange As Range
Set myrange = Union(Cells(2, 1), Cells(2, 4), Cells(2, 7), Cells(2, 10))