VBA Message box to popup and allow user to work within the sheet, upon closing start the code again

Knockoutpie

Board Regular
Joined
Sep 10, 2018
Messages
116
Office Version
  1. 365
Platform
  1. Windows
I am automating a report, but there are a few sections which would be easier to manually adjust than to automate.

I have a popup box right now that pauses the code and allows the user to make manual adjustments, upon closing the box the code will continue.

I need this to happen 3-4 times now, and i'm getting a duplicate scope error.

Any one have a solution or alternatives?

VBA Code:
' Pause the script for manual input
  UserForm1.Label1 = "Make some changes, close or click OK when done"
'  MsgBox "Make changes..."

  On Error GoTo Continue
  UserForm1.Show vbModeless
  Do While Not UserForm1.Visible
    DoEvents
  Loop
  Do While UserForm1.Visible
    DoEvents
  Loop
Continue:

'  MsgBox "Let's go!"
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
I'm not sure that you need those loops at all. DoEvents does not provide much benefit if all the user is doing is changing cells on the spreadsheet. But you can at least get rid of one.

VBA Code:
    On Error GoTo Continue
    UserForm1.Show vbModeless
    Do While UserForm1.Visible
        DoEvents
    Loop
Continue:
 
Upvote 0
I'm not sure that you need those loops at all. DoEvents does not provide much benefit if all the user is doing is changing cells on the spreadsheet. But you can at least get rid of one.

VBA Code:
    On Error GoTo Continue
    UserForm1.Show vbModeless
    Do While UserForm1.Visible
        DoEvents
    Loop
Continue:
This is the same error i've been running into.
 

Attachments

  • Capture.PNG
    Capture.PNG
    19.7 KB · Views: 14
Upvote 0
You have not shown me enough code to be sure, but I think you are using the label "Continue:" more than once in the same sub. You can't do that.
 
Upvote 0
Solution
Oh, thank you, I see, I have to adjust this is using more than once..
On Error GoTo Continue
to
On Error GoTo Continue1
to
On Error GoTo Continue2

etc etc
You have not shown me enough code to be sure, but I think you are using the label "Continue:" more than once in the same sub. You can't do that.
 
Upvote 0
Oh, thank you, I see, I have to adjust this is using more than once..
On Error GoTo Continue
to
On Error GoTo Continue1
to
On Error GoTo Continue2

etc etc
I doubt referencing a label more that once would do it. It's declaring it more than once in the same sub that's a problem
1688665021423.png
 
Upvote 0
I doubt referencing a label more that once would do it. It's declaring it more than once in the same sub that's a problem
View attachment 94851
VBA Code:
Sorry, below example.
    On Error GoTo Continue1
    UserForm1.Show vbModeless
    Do While UserForm1.Visible
        DoEvents
    Loop
Continue1:
'''''''''
    On Error GoTo Continue2
    UserForm1.Show vbModeless
    Do While UserForm1.Visible
        DoEvents
    Loop
Continue2:

instead of''''''''''''''''''''''''''''

    On Error GoTo Continue
    UserForm1.Show vbModeless
    Do While UserForm1.Visible
        DoEvents
    Loop
Continue:
''''''''''''''
    On Error GoTo Continue
    UserForm1.Show vbModeless
    Do While UserForm1.Visible
        DoEvents
    Loop
Continue:
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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