#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 421
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"