B
burl_h
I'm having a problem with the following code, for some reason I can't
get the correct syntax.
Sub delete_not_date
Dim datarng As Range
lastrow = Cells(rows.Count, "B").End(xlUp).Row
Set datarng = Range("b2:b" & lastrow)
For i = lastrow To 1 Step -1
For Each cell In datarng
If Not cell.Format = "mm/dd/yyyy" Then
cell.EntireRow.Delete
End If
Next cell
Next i
End Sub
My problem is the date format, I tried many variations but can't get
anything to work.
I did check the format on the cells and found them to be a custom
format written as "mm\/mm\/yyyy". The data originated from a Crystal
report, hence perhaps the weird date format.
The objective is to delete all rows that don't contain a date value.
Thanks.
get the correct syntax.
Sub delete_not_date
Dim datarng As Range
lastrow = Cells(rows.Count, "B").End(xlUp).Row
Set datarng = Range("b2:b" & lastrow)
For i = lastrow To 1 Step -1
For Each cell In datarng
If Not cell.Format = "mm/dd/yyyy" Then
cell.EntireRow.Delete
End If
Next cell
Next i
End Sub
My problem is the date format, I tried many variations but can't get
anything to work.
I did check the format on the cells and found them to be a custom
format written as "mm\/mm\/yyyy". The data originated from a Crystal
report, hence perhaps the weird date format.
The objective is to delete all rows that don't contain a date value.
Thanks.