0

In Excel I'm looking for a way to close and reopen multiple modal userforms via VBA, which previously were opened manually.

Opening both modal userforms manually works fine: The first userform was opened by clicking a button (activx) on a worksheet, the second userform is opend by clicking a button (commandbutton2) on the first userform.

In order to apply updates to the worksheet I need to close both userforms temporary. I tried the following code:

userform2.hide 'needs to be hidden before hiding the first userform, since both forms are modal
userform1.hide
userform1.show
userform2.show

This, of course, doesn't work properly since the code execution get halted by forms that open modal. Using UserformX.show vbModeless would allow the code to execute but it will also allow the user to access the worksheet without closing the forms which I don't want.

What would be a possible solution here?

EDIT: There is supposed to be a solution by using Application.OnTime from this answer unfortunately I couldn't get to work (assuming it works at all).

Albin
  • 1,000
  • 1
  • 11
  • 33

1 Answers1

0

I managed to open multiple cascaded modal userforms by using events (like activate etc.). This way showing the first modal form triggers the event which shows the second one etc.

Albin
  • 1,000
  • 1
  • 11
  • 33