UserForm to deactivate after first use

harveya915

Board Regular
Joined
Sep 4, 2015
Messages
141
I have a UserForm that pops up when the Sheet is opened for the first time. The UserForm only contains instructions and an "OK" button that makes the UserForm unload. The only problem now is that the UserForm will be popping up every time the sheet is opened.
Is there a way for the User Form to only pop up the first time the sheet is opened?
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Static boolean flag can be used, something like this:
Rich (BB code):
Private Sub Worksheet_Activate()
  Static IsOpen As Boolean
  If IsOpen Then Exit Sub
  UserForm1.Show
  IsOpen = True
End Sub
 
Upvote 0
Well...For the Workbook I have:

Private Sub Workbook_Open()
UserForm1.Show
End Sub

For the UserForm I have:

Private Sub CommandButtion1_Click()
Unload UserForm1
End Sub

Hope this is what you were asking for.
 
Upvote 0
Static boolean flag can be used, something like this:
Rich (BB code):
Private Sub Worksheet_Activate()
  Static IsOpen As Boolean
  If IsOpen Then Exit Sub
  UserForm1.Show
  IsOpen = True
End Sub

I do apologize, but I'm not good at this, I'm very new at this. Would you be able to tell me where exactly do I put this code?
 
Upvote 0
Replace the previous code of Workbook_Open by this one:
Rich (BB code):
Private Sub Workbook_Open()
  If GetSetting(AppName:="HarveyaApp", Section:="Startup", Key:="Ok", Default:="0") = "0" Then
    SaveSetting AppName:="HarveyaApp", Section:="Startup", Key:="Ok", setting:="1"
    UserForm1.Show
  End If
End Sub
 
Upvote 0
And just for the debugging purpose, this code will add one more popup ability:
Rich (BB code):
Sub RestorePopUp()
  DeleteSetting AppName:="HarveyaApp", Section:="Startup", Key:="Ok"
End Sub
 
Upvote 0
I would do it slightly differently.
I would write a ShowInstructions sub, and have that called from the (one time) workbook Open event.
That way, the user could look at the instructions whenever they wanted (by calling ShowInstructions), but it would be forced on them only once.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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