Link to home
Start Free TrialLog in
Avatar of John Sheehy
John SheehyFlag for United States of America

asked on

On load or On open in Excel

So I have this form that is displayed in one my excel workbooks.  I need a few lines of code to run right when the form pop ups.  I normally work in access and would sue an On_Load or On_Open event, but excel does not have that.

What can I use instead to run these commands when the form opens.

Thanks
John
ASKER CERTIFIED SOLUTION
Avatar of Professor J
Professor J

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of John Sheehy

ASKER

I have a button on a worksheet.  The user clicks the button and opens a user form.

When that user form opens I need certain button on it to be disabled right off the bat.

Is that better?

John
Add the code to the same script as opening the form.

Sub OpenForm()

UserForm1.Show
next steps

End Sub

Open in new window

Just re-reading, if a button on the form is to be disabled straight away, why bother with it being there?
The button will enable itself once one of the lines on the form is filled.  It shows the user their options but let's them know required information is missing.  Where I work we need to think of every possibly question a user could have.

I did try your suggestion but it did nothing until the form was no longer showing and then it proceeded to the next line.

But this did work.

UserForm_Initialize()

And I disabled the buttons that needed to be.

Thanks
John