Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default How to I reference in VB a button used to run an Excel macro

Is there a way to reference objects in a VB macro that have been assigned the
same macro?

My application involves several different objects in a worksheet used to
launch a macro that differs only slightly depending on which object is
clicked. If I can ID the object in the code, I can combine the different
macros and just include some IF..THEN statements relating to the object
clicked.

Thx...

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How to I reference in VB a button used to run an Excel macro

Maybe you can use application.caller to get the name of the object.

Add

Msgbox application.caller

to the top of your code and you'll see the names you should use to compare.

VicWestVan wrote:

Is there a way to reference objects in a VB macro that have been assigned the
same macro?

My application involves several different objects in a worksheet used to
launch a macro that differs only slightly depending on which object is
clicked. If I can ID the object in the code, I can combine the different
macros and just include some IF..THEN statements relating to the object
clicked.

Thx...


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default How to I reference in VB a button used to run an Excel macro

Dave...

Your suggestion did exactly what I wanted.... thx much

"Dave Peterson" wrote:

Maybe you can use application.caller to get the name of the object.

Add

Msgbox application.caller

to the top of your code and you'll see the names you should use to compare.

VicWestVan wrote:

Is there a way to reference objects in a VB macro that have been assigned the
same macro?

My application involves several different objects in a worksheet used to
launch a macro that differs only slightly depending on which object is
clicked. If I can ID the object in the code, I can combine the different
macros and just include some IF..THEN statements relating to the object
clicked.

Thx...


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default How to I reference in VB a button used to run an Excel macro

If the objects are shapes or controls from the control toolbox you can use
application.caller

sName = application.caller

sName will hold the name of the object.

--
Regards,
Tom Ogilvy


"VicWestVan" wrote:

Is there a way to reference objects in a VB macro that have been assigned the
same macro?

My application involves several different objects in a worksheet used to
launch a macro that differs only slightly depending on which object is
clicked. If I can ID the object in the code, I can combine the different
macros and just include some IF..THEN statements relating to the object
clicked.

Thx...

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
How to reference MSNStockQuote button within a macro tfrentz Excel Worksheet Functions 2 February 26th 07 03:13 PM
Macro Relative reference button greyed out. J Shrimps, Jr. Excel Programming 1 March 9th 06 03:40 AM
Recording new excel macro, relative reference button doesn't show Dano New Users to Excel 3 August 23rd 05 07:36 PM
relative reference button on end macro menu RobC[_2_] Excel Programming 4 March 2nd 04 09:24 PM
Create button with addin/reference macro in another file netzig Excel Programming 2 February 6th 04 10:36 PM


All times are GMT +1. The time now is 11:11 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"