Avatar of John Sheehy
John Sheehy
Flag 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
Microsoft ExcelVisual Basic Classic

Avatar of undefined
Last Comment
John Sheehy

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Professor J

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
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
Rob Henson

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

Sub OpenForm()

UserForm1.Show
next steps

End Sub

Open in new window

Rob Henson

Just re-reading, if a button on the form is to be disabled straight away, why bother with it being there?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
John Sheehy

ASKER
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