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?
 
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.
Hi Mike,
Thanks, your suggestion is more user-freandly.
Here is the implementation:
Rich (BB code):
' Put all the code to ThisWorkbook module
 
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"
    ShowInstructions
  End If
End Sub
 
Sub ShowInstructions()
  ' Assign Help button/shape to this sub to see the Instructions in UserForm1 anytime
  UserForm1.Show
End_Sub
 
Private Sub RestorePopUp()
  ' For debugging purpose only - add one more auto-popup ability
  DeleteSetting AppName:="HarveyaApp", Section:="Startup", Key:="Ok"
End Sub
Vlad
 
Last edited:
Upvote 0

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Well that is a different story.
In your original post you said:
I have a UserForm that pops up when the
Sheet
is opened for the first time
And sheets are not opened. Sheets are activated.


I do apologize. I am new. I really don't know the difference between sheet and workbook.

But now I know there is a difference.
 
Upvote 0
Hi Mike,
Thanks, your suggestion is more user-freandly.
Here is the implementation:
Rich (BB code):
' Put all the code to ThisWorkbook module
 
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"
    ShowInstructions
  End If
End Sub
 
Sub ShowInstructions()
  ' Assign Help button/shape to this sub to see the Instructions in UserForm1 anytime
  UserForm1.Show
End_Sub
 
Private Sub RestorePopUp()
  ' For debugging purpose only - add one more auto-popup ability
  DeleteSetting AppName:="HarveyaApp", Section:="Startup", Key:="Ok"
End Sub
Vlad



I'm curious to know, does it have to say "HarveyApp"? Or do i substitute this for something else?
 
Upvote 0
I'm curious to know, does it have to say "HarveyApp"? Or do i substitute this for something else?
You may change "HarveyaApp" across the code to "MyApp" or something similar.
It's the name saved in the registry of a computer.
Read more details in VBA help for the SaveSetting function.
 
Last edited:
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



What does this one do exactly? And where does it go? Does it go in ThisWorkbook?
 
Upvote 0
What does this one do exactly? And where does it go? Does it go in ThisWorkbook?
Code of RestorePopUp deletes the previosly saved (via Workbook_Open) registry setting.
After such a deleting the UserForm1 will be shown once again at opening of Workbook.
You may put code of RestorePopUp to any VBA module including ThisWorkbook module.
In the top comment line of the code in post #11 it is recommended to 'Put all the code to ThisWorkbook module
 
Last edited:
Upvote 0
Hi Mike,
Thanks, your suggestion is more user-freandly.
Here is the implementation:
Rich (BB code):
' Put all the code to ThisWorkbook module
 
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"
    ShowInstructions
  End If
End Sub
 
Sub ShowInstructions()
  ' Assign Help button/shape to this sub to see the Instructions in UserForm1 anytime
  UserForm1.Show
End_Sub
 
Private Sub RestorePopUp()
  ' For debugging purpose only - add one more auto-popup ability
  DeleteSetting AppName:="HarveyaApp", Section:="Startup", Key:="Ok"
End Sub
Vlad


I'm getting a Compile error: Ambiguous name detected: Workbook_Open
Any help with this?
 
Upvote 0
Did some reading, and it's basically saying i'm using Workbook_Open twice. I'm guessing I just have to remove the duplicate.
 
Upvote 0
Did some reading, and it's basically saying i'm using Workbook_Open twice. I'm guessing I just have to remove the duplicate.
Yes, delete the previous Workbook_Open subroutine
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,874
Members
452,363
Latest member
merico17

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