![]() |
Code in Sub OKButton_Click to trigger actions depending on calling macro
Hello,
I'm looking for appropriate code in de OKButton of a multi item listbox. This code should trigger different actions depending on which procedure the UserForm was called from. I mean if the UserForm is called by macro A the action should be aaaa and if it is called by macro B the action should be bbbb etc. How can I refer to the calling macro in the OK Button code ? Thanks a lot Herman |
Code in Sub OKButton_Click to trigger actions depending on calling macro
Herman,
There is no built in way to determine what macro called the form. You could add a Public variable to the form, set that variable to the macro name prior to showing the form, then test that variable when OK is clicked. E.g., ' in the form's code module Public CallingMacro As String Public Sub OKButton_Click() If CallingMacro = "A" Then aaaa ElseIf CallingMacro = "B" Then bbb ' and so on End If End Sub Then, in the procedures that call the form, UserForm1.CallingMacro = "A" UserForm1.Show -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Herman" wrote in message m... Hello, I'm looking for appropriate code in de OKButton of a multi item listbox. This code should trigger different actions depending on which procedure the UserForm was called from. I mean if the UserForm is called by macro A the action should be aaaa and if it is called by macro B the action should be bbbb etc. How can I refer to the calling macro in the OK Button code ? Thanks a lot Herman |
All times are GMT +1. The time now is 08:41 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com