Pause Macro

  • Thread starter Thread starter Jennifer
  • Start date Start date
J

Jennifer

Is there a way to force a macro to pause when using the runmacro, repeat x
times.

It seems that excel is unable to paste the exported data quickly enough, so
the exports are not working when the runmacro is used. Manually re-running
the macro works perfectly.

Open Query (30) Make HSD3 based pm Form)
Rename (=[Forms]![County with Contracts]![County])
Transfer Spreadsheet (="O:\Ovations\_ReoccurringProjects\CMS\_Current
Deliverables\" & [Forms]![County with Contracts]![ContractNbr] & " HSD3.xls")
DeleteObject:=[Forms]![County with Contracts]![County]
GoToRecord (next)

I can run the macro manually without errors, but if I use a runmacro with a
repeat count the exports are all screwed up. The exports end up in one excel
file with the first contract number and only some of the counties are in the
export.
 
Create a VBA function to Sleep.

Function Sleep (lngTimes as long) as Boolean
Dim i as Long

For i = 1 to lngTimes
DoEvents
Next i

End Function

Call the function from the Macro. Send the value depending on how much time
you need. e.g. RunCode Sleep(1000)
 
Back
Top