Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Which control caused the macro to run?

Hi!

I have multiple controls (checkboxes) that I've tied to the same macro with
the OnAction property. How do I find out which control triggered the macro. I
guess that I could dynamically add a unique version of the same macro to all
the different controls, but I'd rather have one version of the macro work for
all the controls.

Thanks,
Jonas

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Which control caused the macro to run?

What sort of checkboxes?

Forms Toolbar?

Select Case Application.Caller
Case "Check Box 1": MsgBox "Checkbox1"
Case "Check Box 2": MsgBox "Checkbox2"
Case "Check Box 3": MsgBox "Checkbox3"
End Select


--
HTH

Bob Phillips

"josa01" wrote in message
...
Hi!

I have multiple controls (checkboxes) that I've tied to the same macro

with
the OnAction property. How do I find out which control triggered the

macro. I
guess that I could dynamically add a unique version of the same macro to

all
the different controls, but I'd rather have one version of the macro work

for
all the controls.

Thanks,
Jonas



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Which control caused the macro to run?

Application.Caller was exactly what I was looking for. Thank you all for
taking the time to answer my question.

/Jonas

"Bob Phillips" wrote:

What sort of checkboxes?

Forms Toolbar?

Select Case Application.Caller
Case "Check Box 1": MsgBox "Checkbox1"
Case "Check Box 2": MsgBox "Checkbox2"
Case "Check Box 3": MsgBox "Checkbox3"
End Select


--
HTH

Bob Phillips

"josa01" wrote in message
...
Hi!

I have multiple controls (checkboxes) that I've tied to the same macro

with
the OnAction property. How do I find out which control triggered the

macro. I
guess that I could dynamically add a unique version of the same macro to

all
the different controls, but I'd rather have one version of the macro work

for
all the controls.

Thanks,
Jonas




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Which control caused the macro to run?

Hi Jonas,

Look at the Caller property in VBA help.

To demonstrate, assign the following macro to a control:

Sub ATest()
MsgBox Application.Caller
End Sub

---
Regards,
Norman



"josa01" wrote in message
...
Hi!

I have multiple controls (checkboxes) that I've tied to the same macro
with
the OnAction property. How do I find out which control triggered the
macro. I
guess that I could dynamically add a unique version of the same macro to
all
the different controls, but I'd rather have one version of the macro work
for
all the controls.

Thanks,
Jonas



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 292
Default Which control caused the macro to run?

Hi Jonas

Application.Caller
will return the control name.

HTH. Best wishes Harald

"josa01" skrev i melding
...
Hi!

I have multiple controls (checkboxes) that I've tied to the same macro
with
the OnAction property. How do I find out which control triggered the
macro. I
guess that I could dynamically add a unique version of the same macro to
all
the different controls, but I'd rather have one version of the macro work
for
all the controls.

Thanks,
Jonas





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
What caused this? Yrrep Excel Worksheet Functions 0 March 2nd 10 12:30 AM
FORMULA ERRORS CAUSED BY SPACEBAR Gator Girl Excel Worksheet Functions 12 January 12th 09 09:59 PM
using a cell value to control a counter inside a macro and displaying macro value ocset Excel Worksheet Functions 1 September 10th 06 05:32 AM
Error caused by *.xls file WLMPilot Excel Discussion (Misc queries) 0 July 27th 06 03:09 PM
How to know what caused SheetChange event.. Srini Excel Programming 0 April 26th 05 11:22 PM


All times are GMT +1. The time now is 11:44 PM.

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"