intrigued_66
intrigued_66

Reputation: 17220

How to call userform from button on spreadsheet?

I have my initialiser function within the userform "module" but when I go to assign a function to be called from my button, excel doesnt show the userform "module" functions being available.

How can I get my userform to display upon the press of a button from the spreadsheet?

Upvotes: 4

Views: 121269

Answers (3)

user10818876
user10818876

Reputation: 11

If you want to easily call-up your form on the worksheet without going to VBE, you can simply create a macro (not with PrivateSub) with:

Sub CommandButton_Click ()
UserForm1.Show
End Sub

Upvotes: 0

datatoo
datatoo

Reputation: 2049

double-click the button you have created and place the call to your macro in the code that displays

Private Sub CommandButton1_Click()
UserForm1.Show
End Sub

Upvotes: 10

xchiltonx
xchiltonx

Reputation: 2031

You need to cut/paste your code in to a worksheet macro: 1. select and cut your macro 2. double click on sheet1 (Microsoft Excel Objects) 3. paste 4. save Now you can run your macro

EDIT: Module if I remember correctly are reserved for OnAction

Upvotes: 1

Related Questions