clear cells if time is < 0400

redspanna

Well-known Member
Joined
Jul 27, 2005
Messages
1,604
Office Version
  1. 365
Platform
  1. Windows
Hi all,

On worksheet open I want to clear the contents of cells A8:P50 if the date/time in cell AB1 is less than todays date and before the time 0400.

So currently AB1 shows
Code:
16/03/2011  07:32:40

so if the workbook was to be opened now nothing would be cleared however if the worksheet is opened before 0400 then A8:P50 of sheet DATA are cleared.

any help appreciated.
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Perhaps something along the lines of:

Code:
Private Sub Workbook_Open()
    With Sheets("Sheet1")
        If .Range("AB1") < Date + TimeSerial(4,0,0) Then
            .Range("A8:P50").ClearContents
        End If
    End With
End Sub

modify sheet object as appropriate of course
 
Upvote 0
Hi, i have tried this and nothing seems to happen. I need to have a code that clears cell A5 and resets cell D5 to Yes or No



Perhaps something along the lines of:

Code:
Private Sub Workbook_Open()
    With Sheets("Sheet1")
        If .Range("AB1") < Date + TimeSerial(4,0,0) Then
            .Range("A8:P50").ClearContents
        End If
    End With
End Sub

modify sheet object as appropriate of course
 
Upvote 0

Forum statistics

Threads
1,224,548
Messages
6,179,451
Members
452,915
Latest member
hannnahheileen

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