ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Msg Box (https://www.excelbanter.com/excel-programming/414098-msg-box.html)

Alexandre Chauar

Msg Box
 
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



Norman Jones[_2_]

Msg Box
 
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
'<<============



---
Regards,
Norman


"Alexandre Chauar" wrote in message
...
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



Alexandre Chauar

Msg Box
 
Hi Norman,

It worked! Thanks a lot for your help.

Alexandre

"Norman Jones" escreveu na mensagem
...
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
'<<============



---
Regards,
Norman


"Alexandre Chauar" wrote in message
...
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






All times are GMT +1. The time now is 02:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com