|
-
Nov 17th, 2005, 09:46 PM
#1
Thread Starter
New Member
[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
Last edited by davidd31415; Nov 22nd, 2005 at 09:33 PM.
-
Nov 18th, 2005, 10:17 AM
#2
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
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|