Sub DeleteRowWithContents()
'========================================================================
' DELETES ALL ROWS FROM A2 DOWNWARDS WITH THE WORDs "Record Only" IN COLUMN D
'========================================================================
Last = Cells(Rows.Count, "D").End(xlUp).Row
For i = Last To 1 Step -1
If (Cells(i, "D").Value) = "Record Only" Then
'Cells(i, "A").EntireRow.ClearContents ' USE THIS TO CLEAR CONTENTS BUT NOT DELETE ROW
Cells(i, "A").EntireRow.Delete
End If
Next i
End Sub
Hi
Try the code below
Hope it works for you
MarkCode:Sub DeleteRowWithContents() '======================================================================== ' DELETES ALL ROWS FROM A2 DOWNWARDS WITH THE WORDs "Record Only" IN COLUMN D '======================================================================== Last = Cells(Rows.Count, "D").End(xlUp).Row For i = Last To 1 Step -1 If (Cells(i, "D").Value) = "Record Only" Then 'Cells(i, "A").EntireRow.ClearContents ' USE THIS TO CLEAR CONTENTS BUT NOT DELETE ROW Cells(i, "A").EntireRow.Delete End If Next i End Sub
Sub test()
With ActiveSheet
.AutoFilterMode = False
With Range("d1", Range("d" & Rows.Count).End(xlUp))
.AutoFilter 1, "*Record Only*"
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With
End Sub
Sub DateExtract()
Dim DateTime As Range, Cell As Object
Dim FutureDate As Range
Set DateTime = Range("C57:C1000") 'Range containing expected funding date
Set FutureDate = Sheets("Report Roster").Range("H2") 'Range containing current month's date
With ActiveSheet
.AutoFilterMode = False
With Range("A56", Range("M" & DateTime.Rows.Count + 56).End(xlUp))
.AutoFilter 3, ">FutureDate"
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With
[End Code]
My issue I'm having is nothing is being deleted because the criteria in the autofilter is inserting the name >Futerdate. Is there a way to make that variable based on the date I have in my spreadsheet.
More specifically, the date is 3 months from the prior month end date I'm running the report for. So for my April report the date is giving me 7/31/2009. But next month it will be 8/31/2009.