Sunday 9 December 2012

User Form- GUI for macro


MS Excel: Automatically open a Form when spreadsheet is opened in Excel 2003/XP/2000/97


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 "UserForm1" will automatically open.