VBA: Show or load a form when Excel starts

August 13th, 2004 | Categories: VBA | Tags: , ,
-->

If you would like to load a form or run some VBA code when you open an excel workbook, place your code in the Thisworkbook code window and in the Workbook_Open sub.

From your spreadsheet:
1. Press ALT and F11 to open the VB editor
2. Double-click the word ThisWorkbook to open the code window
3. Type the following code in the ThisWorkbook code window

Private Sub Workbook_Open()
UserForm1.Show
End Sub

Sidenote: Replace Userform1 with your form name

4. Close Excel and re-open.

Can't get the tutorial to work for you? Need help with your code?
Get answers right away at our AE Excel Support Forums!
  1. steve
    August 7th, 2008 at 10:06
    Reply | Quote | #1

    thanks for the tips

  2. Ilya
    April 15th, 2009 at 06:23
    Reply | Quote | #2

    great advice thanks a lot!

  3. Jose
    November 19th, 2009 at 19:54
    Reply | Quote | #3

    easy to learn, tool is powerful

  4. Teela
    August 20th, 2010 at 06:38
    Reply | Quote | #4

    Thanks for the tip, it saved me a lot of time… :)

  5. John
    October 4th, 2010 at 03:47
    Reply | Quote | #5

    I have tried this code and it works great from a few computers. However there are a couple of computers at work that when I put the code in for the workbook open() it has given me different errors. I have even tried:

    Private Sub Workbook_Open()
    On Error Resume Next
    Userform1.show
    End Sub

    Now if I open this spreadsheet up from one of the other computers it works and runs just fine. If I write the code in on one of the other computers (that it runs from) and save it, send it back to the computers I had a problem with and it works, until I try to save something in that spreadsheet from that computer.

    Any ideas??