Delete Rows with a specific Date / Time Format

Guzzlr

Well-known Member
Joined
Apr 20, 2009
Messages
946
Office Version
  1. 2016
Platform
  1. Windows
Code:
'Step Through Rows Backwards and Delete Matching Data
    For MyRow = LastRow To 3 Step -1
        If (Cells(MyRow, "K") = Cells(MyRow - 1, "K")) Then
            Rows(MyRow - 1 & ":" & MyRow).Delete
        End If
    Next MyRow

Hello All, the above code is working good for me to find and delete the rows with matching numbers.
I want to shift gears and delete rows that Do Not have the following Date / Time format in Column G:

mm/dd/yyyy 00:00:00

If a row has a Date / Time format in coloumn G other than the above, that row would be deleted.
I'm not having luck trying to get the code to work based on my loop example above

Thanks for the help
 
Code I used:

Code:
  With Range("[B][COLOR="#FF0000"]H1[/COLOR][/B]", Cells(Rows.Count, "H").End(xlUp))
    .Value = Evaluate(Replace("IF(@=INT(@),""#N/A"",IF(@="""","""",@))", "@", .Address))
    .SpecialCells(xlConstants, xlErrors).EntireRow.Delete
  End With
I missed that your headers were on Row 3. Try changing the H1 above to H4.
 
Upvote 0

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
I missed that your headers were on Row 3. Try changing the H1 above to H4.


Changed H1 to H4, it error'd on:
.SpecialCells(xlConstants, xlErrors).EntireRow.Delete

The error was "no cells found" yet I have changed the time to hh:mm:ss
Thanks
 
Upvote 0
Code:
For Each sht In ActiveWorkbook.Worksheets    If sht.Visible And (sht.Name) = "Template" Then
    For r = sht.Cells(sht.Rows.Count, "H").End(xlUp).Row To 4 Step -1
        If (sht.Cells(r, "H").Value) = "hh:mm:ss" Then sht.Rows(r).Delete
    Next r
    End If
Next sht

I've also been trying something like this, but it is skipping by the cells with this time format
 
Upvote 0

Forum statistics

Threads
1,214,986
Messages
6,122,611
Members
449,090
Latest member
vivek chauhan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top