Show UserForm When Excel File Opens

Show UserForm When Excel File Opens

To help users enter data in a workbook, you can create an Excel UserForm, with text boxes and combo boxes. Then, with a quick bit of code, you can show UserForm when Excel file opens, so the form is easy to find and use.

Parts Inventory Data Entry Form

Here is the parts inventory data entry form from the sample file.

Show UserForm When Excel File Opens

In the original UserForm sample file, there was a button on the worksheet, and users could click it to open the UserForm.

userformstart01

Open the UserForm Automatically

In some workbooks, you might want people to get right to work, and see the UserForm immediately.

So, instead of putting a button on the worksheet, for people to click, you can show the UserForm automatically, when the file opens.

Code to Open the Form Automatically

To make the UserForm open automatically, you’ll add a bit of code to the workbook’s code module, in the Workbook_Open procedure.

To add the code:

  • In the UserForm workbook, press Alt + F11, to open the Visual Basic Editor.
  • At the left, in the Project Explorer, find the UserForm workbook, and double-click on its ThisWorkbook module (in the Microsoft Excel Objects folder).

userformstart02

  • At the top left of the main code window, from the Object drop down, select Workbook

userformstart03

  • At the top right, from the Procedure drop down, select Open
  • The Workbook_Open procedure will be automatically created, with the cursor positioned between the first and last lines of code.

userformstart04

  • Where the cursor is flashing, type a line that opens the UserForm. In this example, the UserForm is named frmParts, so type the following line of code in the Workbook_Open event:
    • frmParts.Show

userformstart05

Test the Workbook_Open Code

To test the Workbook_Open code, follow these steps:

  • Save and close the UserForm workbook.
  • Open the workbook, and enable macros, if prompted.
  • The UserForm will open automatically.

______

32 thoughts on “Show UserForm When Excel File Opens”

  1. Hi, Can you tell me what is the coding for bring the data in our desired row using macro after created the userform.
    Example,
    Everyday i am entering data in excel manually.One day i created userform to enter data in that excel.after done everything(create userform&coding),when i am run that userform,the information which i put in the userform overrights the existing line which i typed manually.
    The userform data’s doesn’t start from blank cell or row.it’s over right the existing cell
    I need the assistance for this please

  2. Small question. I can auto open the form as per your instructions for my team. But if I want to edit it, how can I do it. As on click, it loads the form always. How to open the work book for editing .

    1. open the code editor, go to the project tree and open the code from Book1 inside Microsoft Excel Objects.
      You should have something like this:
      Private Sub Workbook_Open()
      UserForm1.Show
      End Sub
      Just erase the second line ! Just leave the workbook sub / end sub.
      cheers

  3. Hello , First of all Thank you for your suggestion. I have tried this code but when userform appears on the screen , when i am click outside of the form ,the form is hidden permanently . can you please tell me some alternative of this problem.Thanks in Advance.

  4. Hi Guys
    I have a problem in that when I use this code (UserForm1.Show) I get the following error message:
    Run time error 424: Object required
    How do I solve this?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.