Article ID: 142528
Article Last Modified on 1/19/2007
A1: 1
A2:
A3: 2
A4:
A5: 3
A6:
A7: 4
A8:
A9: 5
Sub Delete_Every_Other_Row()
' Dimension variables.
Y = False ' Change this to True if you want to
' delete rows 1, 3, 5, and so on.
I = 1
Set xRng = Selection
' Loop once for every row in the selection.
For xCounter = 1 To xRng.Rows.Count
' If Y is True, then...
If Y = True Then
' ...delete an entire row of cells.
xRng.Cells(I).EntireRow.Delete
' Otherwise...
Else
' ...increment I by one so we can cycle through range.
I = I + 1
End If
' If Y is True, make it False; if Y is False, make it True.
Y = Not Y
Next xCounter
End Sub
Additional query words: 5.00c 8.00 XL97 XL98 XL7 XL5
Keywords: kbhowto kbprogramming kbdtacode KB142528