vba excel cell range delete hours in specified range

mike637 used Ask the Experts™
Hello Experts,

I have a range of cells range("A1:M20") with varied times.  One time is in each cell; there are no calculations in the sheet.   I need to delete any time greater than 2:00:00 AM and less than 5:00:00 A.M.  

I have tried numerous things, but now I need to ask the experts.

Can you please help?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You can try this macro

Sub deltrange()
For Each cel In Range("A1:M20")
If cel.Value > 2 / 24 And cel.Value < 5 / 24 Then cel.ClearContents
Next cel
End Sub



Thank you.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial