Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to Look for Text and then Perform Specified Actions SeventhFloorProfessor Excel Discussion (Misc queries) 1 February 6th 09 03:14 PM
Modify Macro Code Depending on Excel Version John Taylor Excel Discussion (Misc queries) 11 February 26th 07 04:19 AM
Repeat Code Repetitive Actions? chris Excel Discussion (Misc queries) 2 February 18th 05 11:30 PM
Calling an XLA macro from code Chrissy[_4_] Excel Programming 2 October 11th 03 04:38 PM


All times are GMT +1. The time now is 03:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"