VBA to find values between a range of specific times and replace.

RedOctoberKnight

Board Regular
Joined
Nov 16, 2015
Messages
150
Office Version
  1. 2016
Platform
  1. Windows
Good Morning,

I have the following code that I'm hoping to adapt so that I can find specific times that fall within a range and replace them with a "".

VBA Code:
Range("AC17:AC57").Replace What:="12:00:00 AM", Replacement:="", ReplaceFormat:=False

Ultimately I want it to find times between "12:00:00 AM" and "05:00:00 AM" and replace them with a "".

Any insight or direction would be much appreciated.

Thanks
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
What data is currently in those cells? Is it date and time or just time?
 
Upvote 0
Try this on a copy of your workbook

VBA Code:
Sub RemoveTime()
    Dim r As Range, c As Range
    
    Set r = Application.InputBox("Select Range", "Remove Time", , , , , , 8)
    
    If Not r Is Nothing Then
        
        For Each c In r
            If c >= 0 And c <= 0.208333333333333 Then c = ""
        Next
    
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,945
Messages
6,122,395
Members
449,081
Latest member
JAMES KECULAH

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