+ Reply to Thread
Results 1 to 3 of 3

Can you pass a button name to a macro?

  1. #1
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    615

    Can you pass a button name to a macro?

    There is probably some other way to do this, but I have 15 "shapes" that are buttons by means of attaching a macro to each, one for each team member.

    It would be pretty lame to copy the same macro for each of the 15 buttons when the only thing that changes each time is a named range that gets copied for pasting later on in the macro.

    If I could tell the code which shape-button was clicked I could then use something like a case statement (my personal memory has fragments of coding in it, it has been a while) so if button "shape01" was clicked, the named range is "PersonRange01" and so on.

    Can this be done, or do I need to crank it up a notch and use a group of form buttons, or "worse"(?) yet, activeX controls? Is there an advantage as to one or the other in the event I do have a choice?

    Thank-you!

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Can you pass a button name to a macro?


    You can retrieve the shape name calling the macro via Application.Caller

  3. #3
    Forum Contributor
    Join Date
    03-05-2007
    Location
    Falmouth, VA now, Palm Bay, FL for 2 yrs, was Colorado Springs, CO for ten years; Cedark Park, TX; Zeeland, MI; Wilmette, IL; Princeton Junction, NJ; NY, NY
    MS-Off Ver
    365
    Posts
    615

    Re: Can you pass a button name to a macro?

    Thank-you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Can't pass values to module from a Userform (button)
    By Francisco Sousa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-22-2013, 08:20 PM
  2. Pass Values From Array to a Range using command button
    By blackrock41 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-06-2013, 02:40 AM
  3. [SOLVED] Analyze Within An Array and Pass Back Once vs. Pass at each applicable Instance
    By AlvaroSiza in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-11-2012, 05:25 PM
  4. Display Comments when mouse pass over a button
    By sanmisds1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-13-2008, 04:24 PM
  5. Display Comments when mouse pass over a button
    By mmf in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-25-2008, 04:28 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1