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

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
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.
 
Upvote 0

Forum statistics

Threads
1,214,946
Messages
6,122,401
Members
449,081
Latest member
JAMES KECULAH

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
Back
Top