You should go to this site and download Andrew's Utilities ( one of the great
thing I have found here)
It has so many functions, that I still to this day have not tried all of them
http://www.andrewsexceltips.com
Below is an exsample of one of the Sub's in that menu, which deletes rows
under certain conditions, like every 2nd row....or 5th row.
try it out first to see which rows it actually deletes on a copy of your
workbook first .
Sub DeleteRowsConditionally()
' Original VBA by Masaru Kaji aka Colo, Colo's Junk Room,
http://www.puremis.net/excel
' Modified by Andrew Engwirda, Andrew's Excel Tips,
http://www.andrewsexceltips.com
Dim myValue As String
Dim Proceed As Long
Dim cell As Range
Dim rDelete As Range
On Error GoTo Terminate
myValue = InputBox("Enter your value.", "Delete Rows Conditionally")
If myValue = "" Then Exit Sub
Proceed = MsgBox("Push YES to delete all rows with '" & myValue & "'" &
vbCrLf & vbCrLf & _
"Push NO to delete all rows without '" & myValue & "'"
& vbCrLf & vbCrLf & _
"Push Cancel to exit" & vbCrLf & vbCrLf & _
"Note: Entire rows will be deleted where " & vbCrLf
& _
"matches are found in each selected column.",
vbYesNoCancel, "Delete Rows Conditionally")
Call SetCalcSetting
Select Case Proceed
Case vbYes
For Each cell In Selection
If cell.Value = myValue Then
If rDelete Is Nothing Then
Set rDelete = cell.EntireRow
Else
Set rDelete = Union(rDelete, cell.EntireRow)
End If
End If
Next
rDelete.Delete
Case vbNo
For Each cell In Selection
If cell.Value < myValue Then
If rDelete Is Nothing Then
Set rDelete = cell.EntireRow
Else
Set rDelete = Union(rDelete, cell.EntireRow)
End If
End If
Next
rDelete.Delete
Case Else
End Select
Terminate:
Call SetCalcSetting("Restore")
End Sub
"Brandon Horne" wrote:
I have looked online and only found a macro that would delete every even row.
I have a recurring job that requires me to delete every odd row. Could
someone please help me with this.
Thanks,
Brandon