ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating Message Box Warning (https://www.excelbanter.com/excel-programming/367616-creating-message-box-warning.html)

Mariner

Creating Message Box Warning
 
I want to put various times into an excel spreadsheet, when these times are
reached I need excel to display a message box with a warning and a ok button
to acknowledge. Any ideas how to go about this.

NickHK

Creating Message Box Warning
 
You can enter a date/time in a range, say A1.
Then in the Open, SelectionChange or Change events of the worksheet, compare
the value to the current time.

If Range("A1").Value<Now() Then
MsgBox "Time passed"
End

Is that what you mean ?

NickHK

"Mariner" wrote in message
...
I want to put various times into an excel spreadsheet, when these times

are
reached I need excel to display a message box with a warning and a ok

button
to acknowledge. Any ideas how to go about this.




skatonni via OfficeKB.com

Creating Message Box Warning
 
Try Excel's OnTime. Here is an example to start you off.

Enter a date (with time) in cell A4 and another in A5. Run the setTimes
macro.

Sub setTimes()

Application.OnTime earliesttime:=Range("A4"), procedu="RunWhat", _
schedule:=True, latesttime:=Range("A4") + TimeSerial(0, 0, 30)

Application.OnTime earliesttime:=Range("A5"), procedu="RunWhat", _
schedule:=True, latesttime:=Range("A5") + TimeSerial(0, 0, 30)

End Sub

Sub RunWhat()
MsgBox "The time is " & Now()
End Sub


Mariner wrote:
I want to put various times into an excel spreadsheet, when these times are
reached I need excel to display a message box with a warning and a ok button
to acknowledge. Any ideas how to go about this.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200607/1

Mariner

Creating Message Box Warning
 
Hello
I am trying to get this to work but as I am new to this, where do I put the
code.

Thanks

"skatonni via OfficeKB.com" wrote:

Try Excel's OnTime. Here is an example to start you off.

Enter a date (with time) in cell A4 and another in A5. Run the setTimes
macro.

Sub setTimes()

Application.OnTime earliesttime:=Range("A4"), procedu="RunWhat", _
schedule:=True, latesttime:=Range("A4") + TimeSerial(0, 0, 30)

Application.OnTime earliesttime:=Range("A5"), procedu="RunWhat", _
schedule:=True, latesttime:=Range("A5") + TimeSerial(0, 0, 30)

End Sub

Sub RunWhat()
MsgBox "The time is " & Now()
End Sub


Mariner wrote:
I want to put various times into an excel spreadsheet, when these times are
reached I need excel to display a message box with a warning and a ok button
to acknowledge. Any ideas how to go about this.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200607/1


skatonni via OfficeKB.com

Creating Message Box Warning
 
Alt + F11 opens the Visual Basic Editor.
Insert menu | Module
Paste the code.
Click anywhere in the setTimes code.
Run with the F5 button. (When you learn more you won't have to open up the
editor to run the code.)

Mariner wrote:
Hello
I am trying to get this to work but as I am new to this, where do I put the
code.

Thanks

Try Excel's OnTime. Here is an example to start you off.

[quoted text clipped - 18 lines]
reached I need excel to display a message box with a warning and a ok button
to acknowledge. Any ideas how to go about this.


--
Message posted via http://www.officekb.com

Mariner

Creating Message Box Warning
 
Thank you Skatonni this is great.
Is it possible to display say for example "message A" when the cell A4
procedure runs and a different message for example "message B" when cell A5
procedure runs.

"skatonni via OfficeKB.com" wrote:

Alt + F11 opens the Visual Basic Editor.
Insert menu | Module
Paste the code.
Click anywhere in the setTimes code.
Run with the F5 button. (When you learn more you won't have to open up the
editor to run the code.)

Mariner wrote:
Hello
I am trying to get this to work but as I am new to this, where do I put the
code.

Thanks

Try Excel's OnTime. Here is an example to start you off.

[quoted text clipped - 18 lines]
reached I need excel to display a message box with a warning and a ok button
to acknowledge. Any ideas how to go about this.


--
Message posted via http://www.officekb.com


skatonni via OfficeKB.com

Creating Message Box Warning
 
In the OnTime statement for A5 change RunWhat to anything else, perhaps
RunWhatA5

Application.OnTime earliesttime:=Range("A5"), procedu="RunWhatA5", _
schedule:=True, latesttime:=Range("A5") + TimeSerial(0, 0, 30)

Add this third macro

Sub RunWhatA5()
MsgBox "message B"
End Sub


Mariner wrote:
Thank you Skatonni this is great.
Is it possible to display say for example "message A" when the cell A4
procedure runs and a different message for example "message B" when cell A5
procedure runs.

Alt + F11 opens the Visual Basic Editor.
Insert menu | Module

[quoted text clipped - 14 lines]
reached I need excel to display a message box with a warning and a ok button
to acknowledge. Any ideas how to go about this.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200607/1

Mariner

Creating Message Box Warning
 
Thank You

"skatonni via OfficeKB.com" wrote:

In the OnTime statement for A5 change RunWhat to anything else, perhaps
RunWhatA5

Application.OnTime earliesttime:=Range("A5"), procedu="RunWhatA5", _
schedule:=True, latesttime:=Range("A5") + TimeSerial(0, 0, 30)

Add this third macro

Sub RunWhatA5()
MsgBox "message B"
End Sub


Mariner wrote:
Thank you Skatonni this is great.
Is it possible to display say for example "message A" when the cell A4
procedure runs and a different message for example "message B" when cell A5
procedure runs.

Alt + F11 opens the Visual Basic Editor.
Insert menu | Module

[quoted text clipped - 14 lines]
reached I need excel to display a message box with a warning and a ok button
to acknowledge. Any ideas how to go about this.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200607/1



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

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