Link to home
Start Free TrialLog in
Avatar of sonmic
sonmic

asked on

Macro has to work for 2 workbooks

Hi,

I have 2 spreadsheet, Book1 en Book2.
I start Book1 and automatically in de OnOpen events starts the macro.
A number of functions are executed and then spreadsheet Book2 will be openend.
Now de execution of the macro should be stopped temporarily. The user has to change 1 field in Book2 and then the processing of the macro has to be continued.
I have tried a lot of code but i can't stop the macro temporarily.

gtz
Avatar of SiddharthRout
SiddharthRout
Flag of India image

Here is one way.

Paste this in a module. The second part of the macro will continue after 15 seconds so the user has 15 seconds to make the changes. You may amend that as applicable.

Sub Sample()
    Dim wb1 As Workbook, wb2 As Workbook
    
    Set wb1 = ActiveWorkbook
    
    Set wb2 = Workbooks.Open("C:\Book2.xls")
    
    '~~> Wait for 15 seconds
    Application.OnTime Now() + TimeValue("00:00:15"), "ContinueCode"

End Sub

Sub ContinueCode()
    MsgBox "Macro Continues"
End Sub

Open in new window


Sid
ASKER CERTIFIED SOLUTION
Avatar of KnutsonBM
KnutsonBM
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
the input box makes it so you don't have to have a preset amount of time to pause the code, and the code doesn't continue until the text is input