OnLoad / buttons on worksheet itself

melibeth

New Member
Joined
May 9, 2006
Messages
3
How do I show a user form as soon as my .xls file opens?
How to you put a control button on a worksheet and then assign macros to it?
Does anyone know if you can also do this in Word.

Thanks!!!!!!!!!!!!
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

sykes

Well-known Member
Joined
May 1, 2002
Messages
1,884
Office Version
  1. 365
Platform
  1. Windows
1. In the workbook_open event, which is found in the VBA editor, "This Woorkbook" module, enter the line:
Code:
userform1.show

The whole lot should look thus:

Code:
Private Sub Workbook_Open()
userform1.show
End Sub
.............. in both of these cases substituting the userform1 reference to that of your userform in question.
Now, each time your workbook opens, the code will run, and the useform will be shown.

2. Control button.....
Draw the button onto the worksheet, right click/view code/ and put the lines of code inside the two visible lines.

So, if you want a message box to fire from the button, put the line:

Code:
Msgbox "Hello again melibeth!"
within the two sub lines thus:

Code:
Private Sub CommandButton1_Click()
Msgbox "Hello again melibeth!"
End Sub

When you're done, be sure to come out of design mode with your worksheet before trying the button.

3.Yes, you can do this in Word.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,969
Messages
5,856,590
Members
431,823
Latest member
irtezazaz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top