Hi all,
I am creating a macro to delete all rows from a sheet that do not meet a specified date range.
The sheet to delete from is named "PreparedData". The start date and end date of the range are specified in cells G5 and I5 respectively in sheet "Macro". Within the "PreparedData" sheet, the dates are in column BP.
This is what I have so far:
Dim lRow As Long
Dim iCntr As Long
lRow = Sheets("PreparedData").UsedRange.Rows.Count
For iCntr = lRow To 1 Step -1
If Cells(iCntr, BP) < Sheets("Macro").Range("G5").Value Then
Rows(iCntr).Delete
Else
If Cells(iCntr, BP) > Sheets("Macro").Range("G5").Value Then
Rows(iCntr).Delete
End If
I know that this loop is wrong, would anyone be able to help to get this to work?
Thankyou
I am creating a macro to delete all rows from a sheet that do not meet a specified date range.
The sheet to delete from is named "PreparedData". The start date and end date of the range are specified in cells G5 and I5 respectively in sheet "Macro". Within the "PreparedData" sheet, the dates are in column BP.
This is what I have so far:
Dim lRow As Long
Dim iCntr As Long
lRow = Sheets("PreparedData").UsedRange.Rows.Count
For iCntr = lRow To 1 Step -1
If Cells(iCntr, BP) < Sheets("Macro").Range("G5").Value Then
Rows(iCntr).Delete
Else
If Cells(iCntr, BP) > Sheets("Macro").Range("G5").Value Then
Rows(iCntr).Delete
End If
I know that this loop is wrong, would anyone be able to help to get this to work?
Thankyou