Thread: Pop up
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Roger on Excel Roger on Excel is offline
external usenet poster
 
Posts: 249
Default Pop up

Thanks "Gary's Student". - Very clear and concise instructions.\

I have two questions though :

1)How does one make the code run automatically from start of the sheet?
2)How does one enter a specific time and date from when the code activates -
for example after a 10 day trial period from when the sheet is first used -
todays date and time would be useful for experimenting with the code

Many thanks,

Roger

"Gary''s Student" wrote:

Public RunWhen As Double
Public Const cRunIntervalSeconds = 900 ' 15 minutes
Public Const cRunWhat = "The_Sub"
Sub StartTimer()

RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat, _
schedule:=True
End Sub
Sub The_Sub()
'
MsgBox ("fifteen minutes have once again passed")
'
StartTimer

End Sub
Sub StopTimer()
On Error Resume Next
Application.OnTime earliesttime:=RunWhen, _
procedu=cRunWhat, schedule:=False
End Sub


Standard module macros are very easy to install and use:

1. ALT-F11 brings up the VBE window
2. ALT-I
ALT-M opens a fresh module
3. paste the stuff in and close the VBE window

If you save the workbook, the macro will be saved with it.

To remove the macro:

1. bring up the VBE window as above
2. clear the code out
3. close the VBE window

To use the macro from Excel:

1. ALT-F8
2. Select StartTimer
3. Touch RUN
--
Gary''s Student - gsnu200797


"Roger on Excel" wrote:

I have searched the message boards for advice on creating a pop up message
box, but unfortunately I have found the advice on the use of OnTime
confusing. For example, advice is not explicit on where to put various code
in the spreadsheet (e.g., module / This Workbook etc)

What I would like is to have a message box pop up every 15 mins from a
date/time that is stored somewhere in my spreadsheet or more preferably
within the code itself.

From that date/time i would like the message to then pop up every 2 minutes
when the spreadsheet is used.

people quote from the page http://www.cpearson.com/excel/OnTime.aspx,
however i find this site unhelpful on this matter as it assumes expertize on
where to place code.

Can anyone provide specific code together with instructions for where to
place the code such that the code works when the sheet is opened?

Thanks,

Roger