[RESOLVED] Selecting nonAdjacent Cells?
I see from the macro recorder that nonadjacent cells can be selected simultaneously like this:
Range("G17,J34,N19").Select
How can I do this using integers? Range(cells(x,y),cells(i,j)).Select selects an entire region (correct my vocab if incorrect please) and Range(cells(x,y),cells(i,j),cells(a,b)).Select produces a syntax error...
Thanks
Re: Selecting nonAdjacent Cells?
Use the Union method of the Excel application.
Example
VB Code:
Sub DavidRange()
Dim DaveRange As Range
Dim DaveCell As Range
Set DaveRange = Worksheets(1).Cells(1, 1)
Set DaveRange = Application.Union(DaveRange, Worksheets(1).Cells(2, 2))
Set DaveRange = Application.Union(DaveRange, Worksheets(1).Cells(4, 10))
'etc....
For Each DaveCell In DaveRange.Cells
Debug.Print DaveCell.Address
Next DaveCell
End Sub