Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call userform from button on spreadsheet?

Tags:

excel

vba

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?

like image 376
mezamorphic Avatar asked Jan 16 '23 09:01

mezamorphic


2 Answers

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
like image 167
datatoo Avatar answered Jan 28 '23 06:01

datatoo


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

like image 21
xchiltonx Avatar answered Jan 28 '23 08:01

xchiltonx