MS Excel: Automatically open a Form when spreadsheet is opened in Excel 2003/XP/2000/97
Question: In Microsoft Excel 2003/XP/2000/97, I have a form called UserForm1. How do I automatically open the form when the workbook is opened?Answer: There are several "events" available within an Excel spreadsheet where you can place VBA code. In your case, we want to open the form when the "Workbook_Open" event fires.
To do this, press Alt-F11 to go to the Visual Basic editor.
Then select ThisWorkbook in the left window. In the right window, select Workbook in the first drop-down and Open in the second drop down. Then enter the following VBA code:
Private Sub Workbook_Open()
UserForm1.Show
End Sub
Now when the spreadsheet is opened, the form called UserForm1 will automatically open.
0 comments:
Post a Comment