Msg Box

  • Thread starter Thread starter Alexandre Chauar
  • Start date Start date
A

Alexandre Chauar

Hi,

I need to create a very simple sub:

In cell A1 I input a date;
If A1 is different from today, then an Msg Box says "Date is different of
today. Do you wish to continue?
Buttons Ok and Cancel

Can anybody help?

Best regards,
Alexandre
 
Hi Alexandre,

Try something like:

'============>>
Option Explicit

Public Sub Tester001()
Dim WB As Workbook
Dim SH As Worksheet
Dim Rng As Range

Set WB = Workbooks("Test.xls") '<<==== CHANGE
Set SH = WB.Sheets("Sheet1") '<<==== CHANGE
Set Rng = SH.Range("A1")

If Rng.Value <> Date Then
MsgBox Prompt:="Date is different to today. " _
& "Do you wish to continue?", _
Buttons:=vbOKCancel, _
Title:="Date Check"
End If

End Sub
'<<============
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top