Command Button will not change state unless i navigate away from the userForm

rob737

Board Regular
Joined
May 12, 2015
Messages
129
Hi Forum

Hope all is well. I am trying to pause the execution of a sub routing until there is a user intervention, however it seems my userform is not active until I navigate away from it and back.

Excel Version: 2010
Operating System: windows 7
Forum Experience Level: Novice
Programing Level: Novice

Problem: When a loop finishes I want to use the state change of a command button to call the next sub-routine and pass a string value to the sub-routine.

Sub name activeDirectory
String pctCompl


First attempt

Next I ‘ loop has finished
MsgBox " Sub1 Complete ok when ready to continue " ‘ stop and wait for ok
activeDirectory pctCompl
end sub

Works fine but I don’t want to use a msgbox for my user input.



Second attempt

The user form has an option button for the change of state

Next I ‘ Loop finishes and command button is false
Do While UserForm1.OptionButton1.Value = False
Application.Wait Now + TimeValue("00:00:01") ‘ do something innocuous
Loop

activeDirectory pctCompl

End Sub

Does not work, however works if I do the following steps

  1. Wait until the next I loop completes
  2. Select the command button, button does not change its state
  3. toggle away from Userform1 using the keyboard “ Alt” and “Tab” keys to go to a different screen
  4. toggle back
  5. command button has changed its state to true and program works fine

It’s like the Userform1 is disabled for input from its existing controls but if I interrupt it with a msgbox or toggle away it seems to work fine, strange.

Hope someone can assist
Best Regards
Rob
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Forum statistics

Threads
1,202,902
Messages
6,052,451
Members
444,582
Latest member
Scramble

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