Use GetTickCount to pause macro

farmock2

New Member
Joined
Oct 29, 2014
Messages
23
learherhen99 posted the following on March 2,2020 and stated that this worked. I cannot get it to pause a macro. I had a problem with the If Then statements with no End If so I added, The routine would not end and return to the calling routine. Does anybody have any ideas I might try? Thanks in advance.

Sub WasteTime(Finish As Long)

Dim NowTick As Long
Dim EndTick As Long

EndTick = GetTickCount + (Finish * 1000)

Do

NowTick = GetTickCount
DoEvents

Loop Until NowTick >= EndTick

End Sub

Here's the portion of the code where I'm calling to 10 minutes to give the user time:
VBA Code:
'Ask user if NoActivity/Future dates need to be added
Dim Answer As VbMsgBoxResult
Answer = MsgBox("Past, present and/or future dates highlighted will *not* be available on the Timesheet Tab." & _
" Do you need to add 'No Activity' or future dates to the FutureWorking tab?", vbYesNo + vbQuestion + vbDefaultButton2, "No Activity Dates")
'If past/future dates need to be manually copied/pasted, give user 10 minutes
If Answer = vbNo Then
'if no additional updates, move to Timesheetv8 macro
Call Timesheetv8
'if yes, wait for 10 minutes while the information is inputted...
If Answer = vbYes Then
WasteTime (600)

End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Hi Farmok

I always use
VBA Code:
Application.Wait(Now + TimeValue("00:00:01"))

the code above waits 1 second
 
Upvote 0

Forum statistics

Threads
1,215,757
Messages
6,126,693
Members
449,331
Latest member
smckenzie2016

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top