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
 

Some videos you may like

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

EFANYoutube

Board Regular
Joined
May 19, 2017
Messages
162
Hi Farmok

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

the code above waits 1 second
 

Watch MrExcel Video

Forum statistics

Threads
1,127,155
Messages
5,623,074
Members
415,950
Latest member
Kindz

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
Top