MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Selecting alternate rows


Posted by Celia on January 07, 2000 3:24 AM

Would much appreciate if someone could advise how to write a macro that selects every alternate cell in a range.
I need to select all the cells at the same time, not one at a time.


Posted by Chris on January 07, 2000 7:08 AM

Celia,

I'm sure there's a better way, but this will select all the cells in odd rows for the current selection.

Sub SelectOdd()
For Each cell In Selection
If Application.WorksheetFunction.Odd(cell.Row) = cell.Row Then
oRange = oRange & "," & cell.Address
End If
Next cell
oRange = Mid(oRange, 2, Len(oRange) - 1)
Range(oRange).Select
End Sub

HTH,
Chris