How do you open userform in another workbook?

I am trying to open a user form in another workbook. I have an Active X button with the code:

 

Private Sub CommandButton1_Click()
Workbooks("Scoring_Calculator.xlsm").Worksheets("Scoring_Calculator").Activate
Workbooks("Scoring_Calculator.xlsm").Worksheets("Scoring_Calculator").Select
UserForm1.Show
End Sub

 

When I click on the button I get the error 'Object required'. The UserForm1.Show command is where the macro craches. What is the proper syntax for open the user form?

Answer
Answer

Hi,

try this

assuming that you want to open from WB1 the UserForm1 in WB2

 

1) in WB1:

 in a module paste the code below:

 

Sub myMacro()
Workbooks("WB2.xlsm").Activate
Application.Run ActiveWorkbook.Name & "!macro_01"
End Sub

 

2) in WB2:

 in a module paste the code below:

 

Sub macro_01()
UserForm1.Show
End Sub

 

 

run the code myMacro from WB1

 

note: both workbooks are open

 

--------------------------------
Microsoft365 on Windows 10
---------------------------------

3 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated October 18, 2023 Views 11,698 Applies to: