If Date question

Pinaceous

Well-known Member
Joined
Jun 11, 2014
Messages
1,124
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I'm working with this code below that I've pasted into Sheet1 of my workbook:


Code:
Private Sub Workbook_Expired()
 
    With ThisWorkbook.Sheets("Sheet1")
        If Date > (.Range("D3") + 3) Then
            
   
 MsgBox "This Sheet has expired!"
   
        End If
    End With
 
End Sub


I'd like to add this code to include:


Code:
If IsEmpty(Sheet1.Range("D3").Value) Then [QUOTE]Do nothing[/QUOTE]


If someone can help me, I'd appreciate it!

Thanks,
Pinaceous
 
Last edited:

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Try this:
Code:
Private Sub CommandButton1_Click()
'Modified 4-2-18 9:40 PM EDT
    With ThisWorkbook.Sheets("Sheet1")
        If IsEmpty(Sheet1.Range("D3")) Then: Exit Sub
        If Date > .Range("D3") + 3 Then MsgBox "This Sheet has expired!"
    End With
 
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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