Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Switching sheets while timer running

This is the code written in the sheet called "Safety Injection":

Option Explicit

Const WS_RANGE As String = "Q35"

Private mPrev As Variant

Private Sub Worksheet_Calculate()

On Error GoTo ws_exit
Application.EnableEvents = False

If Me.Range(WS_RANGE).Value < mPrev Then
With Me.Range(WS_RANGE)
If .Value = 1 Then
nCount = 15
Call RunTimer
ElseIf .Value = 0 Then
nCount = 0
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
mPrev = Me.Range(WS_RANGE).Value
End Sub


This is the code written in the standard code module:

Public nCount As Long

Public Sub RunTimer()
Dim aWB As Workbook
Dim aWS As Worksheet

Set aWB = ThisWorkbook
Set aWS = aWB.Worksheets("Safety Injection")

If nCount = 0 Then

aWS.Range("W11") = nCount
nCount = nCount - 1
Application.OnTime Now + TimeSerial(0, 0, 1), "RunTimer"
End If
End Sub

Timer is malfunctioning when I try to switch between sheets. I have data
that goes into sheet called "Pressure". This data causes "Q35" on "Safety
Injection" to become either a 1 or a 0. When I manually change the data in
the "Pressure Sheet", timer on "Safety Injection" should starting counting
down from 15 to 0. Timer sometimes doesn't run or it sometimes it starts
counting down by 2's.

Help please...Thanks
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
switching window stops running macros N+ Excel Programming 4 March 12th 08 05:49 PM
Stopping a Timer / Running a timer simultaneously on Excel Paul23 Excel Discussion (Misc queries) 1 March 10th 06 12:08 PM
Running code/switching between sheets Metrazal[_9_] Excel Programming 7 February 24th 06 02:56 PM
running timer JbL Excel Programming 3 November 6th 04 02:09 AM
Switching to other apps while running macros in excel 97 Jon Peltier[_3_] Excel Programming 2 July 11th 03 10:49 PM


All times are GMT +1. The time now is 10:22 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"