Help: Running a userform

daverskully

New Member
Joined
Nov 16, 2010
Messages
15
Hey all, first time here. I'm having a little trouble opening a userform in excel. I've never created a userform before. I have some experience in MS Access, but not much in Excel. The userform I've created is an interface to help users easily enter information, which is then transferred to a worksheet when they click a button. Everything works fine, but I do not know how to run this userform so that it comes up when in a worksheet.

Optimally, I would like to have a button in a worksheet that a user could click on to open this userform window, where they could then enter their info. I keep seeing the following code for doing this, but as a beginner, I do not know exactly how to implement it.

Sub ShowForm()
Form1.Show
End Sub

Any help would be greatly appreciated.

Dave
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Try adding a button from the Controls toolbar, right click it, select View Code and replace any code with

Code:
Private Sub CommandButton1_Click()
UserForm1.Show
End Sub

Then click Exit design mode on the Controls toolbar to make the button active.
 
Upvote 0
if you want the form to appear when the workbook opens, you can add a sub in the 'ThisWorkbook' area in the VBE.

Code:
Sub workbook_open()
    MyUserform.Show
End Sub
 
Upvote 0
Alternatively you could place the .Show command in the worksheet's Activate event so the user form loads whenever the worksheet becomes active.

Just another option...
 
Upvote 0

Forum statistics

Threads
1,223,711
Messages
6,174,025
Members
452,542
Latest member
Bricklin

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