- Code: Select all
Sub countDown()
MsgBox ("Sub countdown called ")
countDownComplete = False
While countDownComplete = False
countDownValue = Range("D2")
hours = Left$(countDownValue, 2)
minutes = Mid$(countDownValue, 4, 2)
Seconds = Right$(countDownValue, 2)
totalSeconds = (hours * 3600)
totalSeconds = totalSeconds + (minutes * 60)
totalSeconds = totalSeconds + (Seconds)
MsgBox (hours & " " & minutes & " " & Seconds & " " & totalSeconds)
If totalSeconds < 5 Then countDownCompleted = True
Range("T1") = totalSeconds
Wend
End Sub
Can anyone please help with the above vba code that I am trying to run using Excel 2007?
The idea is simple enough.
Set countdowncomplete to False
While countdowncomplete=Fallse
Read the time left from cell D2
Split the string into hours, minutes and seconds.
Convert hours, minutes and seconds into totalseconds
OPTION - Print totalseconds as a messagebox
if totalseconds is <5 then set countdowncomplete to true
End while loop
There is some odd behaviour that I don't understand. If I run the sub as above it appears to work perfectly although each iteration stops with a messagebox that needs to be clicked. However, if I comment out the call to the messagebox the sheet freezes as though it were being overloaded by the data from GBA.
Has anyone experienced this before?
TIA
Bassdrinker


