Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Start a macro when a clock goes down to zero

I am trying to make a macro work when a clock count down to zero. I have a
macro that is working when I am in some way activate the worksheet. How can I
activate the worksheet without doing a manual thing in it. I have a clock
running in the worksheet.
My macro looks like this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Select Case Range("E29")
Case Is = 1
Range("E30").Select (This doesn´t happen before I do something
in the
End Select worksheet)

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Start a macro when a clock goes down to zero

You can use the ontime method. For example, the code below will play a sound for each of the
date/times listed in column A of the active sheet. (Just to give you an idea of how it is coded....)

HTH,
Bernie
MS Excel MVP

Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long

Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000

Sub PlayWAV()
WAVFile = "C:\Program Files\Ahead\Nero\Trumpet1.wav"
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End Sub

Sub SetAlarms()
Application.Calculate
Dim myCell As Range
For Each myCell In Range("A1", Range("A65536").End(xlUp))
Application.OnTime myCell.Value, "PlayWAV"
Next myCell
End Sub

Sub CancelAlarms()
Dim myCell As Range
For Each myCell In Range("A1", Range("A65536").End(xlUp))
Application.OnTime myCell.Value, "PlayWAV", , False
Next myCell
End Sub



"BFSWE" wrote in message
...
I am trying to make a macro work when a clock count down to zero. I have a
macro that is working when I am in some way activate the worksheet. How can I
activate the worksheet without doing a manual thing in it. I have a clock
running in the worksheet.
My macro looks like this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Select Case Range("E29")
Case Is = 1
Range("E30").Select (This doesn´t happen before I do something
in the
End Select worksheet)

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Start a macro when a clock goes down to zero

Thanks Bernie.
I will try it tomorrow.
/Bo

"Bernie Deitrick" skrev:

You can use the ontime method. For example, the code below will play a sound for each of the
date/times listed in column A of the active sheet. (Just to give you an idea of how it is coded....)

HTH,
Bernie
MS Excel MVP

Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long

Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000

Sub PlayWAV()
WAVFile = "C:\Program Files\Ahead\Nero\Trumpet1.wav"
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End Sub

Sub SetAlarms()
Application.Calculate
Dim myCell As Range
For Each myCell In Range("A1", Range("A65536").End(xlUp))
Application.OnTime myCell.Value, "PlayWAV"
Next myCell
End Sub

Sub CancelAlarms()
Dim myCell As Range
For Each myCell In Range("A1", Range("A65536").End(xlUp))
Application.OnTime myCell.Value, "PlayWAV", , False
Next myCell
End Sub



"BFSWE" wrote in message
...
I am trying to make a macro work when a clock count down to zero. I have a
macro that is working when I am in some way activate the worksheet. How can I
activate the worksheet without doing a manual thing in it. I have a clock
running in the worksheet.
My macro looks like this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Select Case Range("E29")
Case Is = 1
Range("E30").Select (This doesn´t happen before I do something
in the
End Select worksheet)

End Sub




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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Incremental time values based upon clock in and clock out times saltnsnails Excel Discussion (Misc queries) 8 January 13th 09 08:11 PM
How do I calculate time in excel (clock in and clock out chad Excel Discussion (Misc queries) 3 January 7th 08 10:09 PM
Change EXCEL Clock to Standard Clock or Military Time YoMarie Excel Worksheet Functions 4 April 29th 07 08:39 PM
Calculating Clock start time in Excel Hani Muhtadi Excel Discussion (Misc queries) 1 August 31st 05 10:01 PM
Start Clock/Stop Clock abfabrob Excel Discussion (Misc queries) 9 June 28th 05 04:26 PM


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

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"