Allow User To Edit Worksheet At Certain Point During Macro

Draperies

Board Regular
Joined
Jun 29, 2009
Messages
79
I have a macro that I would like to let a user edit the worksheet and make changes at a certain point. I have tried creating a modeless userform, but the userform only pops up and the code continues running without waiting for input (or running any of the code in the userform). Does anyone know of either another way I can accomplish this or what I would be doing wrong with the userform?
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Try ending the first sub with the modeless userform open and when they click the button on the userform another macro starts from there.

If you want the "Edit mode" to happen only on certain condition you can force the macro to end with something like:
Code:
Sub TheFirstMacro()

Dim Ask As Integer

Ask = MsgBox("Yes or No?", vbYesNo)
    'Yes=6, No=7

If Ask = 7 Then
    MsgBox "You chose No." & vbNewLine & "Macro ends here."
    Exit Sub
End If

Call TheOtherMacro

End Sub

Sub TheOtherMacro()

MsgBox "You chose Yes so this is the other macro."

End Sub
 
Upvote 0
Thank you for the response! Unfortunately when I set the userform to vbModeless the userform only pops up onto the screen, but the code immediately continues to execute and does not allow me to select any buttons.

I did incorporate the message boxes, and that does work great! I just can't get the code to wait once it shows the userform...
 
Upvote 0
Try replacing the MsgBox with your modeless userform followed by Exit Sub: That should do the same trick.
 
Upvote 0
Try this and see if it works for you :

Code:
Sub Test()

    UserForm1.Show vbModeless
    
    Do
        DoEvents
    Loop While VBA.UserForms.Count > 0
    
    MsgBox "Your code is now resuming."
    
    'rest of your code goes here...

End Sub

You should be able to edit the worksheet as well as run any code in the userform.
 
Upvote 0
Jaafar, I had the same problem and looked for hours to find a solution. Your solution was so simple and perfect for my situation.... Nice work!
 
Upvote 0
Same here, pausing and continuing the same code really worked for what I'm doing here. Thanks for the assist.

-- g
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,285
Members
452,902
Latest member
Knuddeluff

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