+ Reply to Thread
Results 1 to 4 of 4

Click a button - pass some information - How To?

  1. #1
    Registered User
    Join Date
    11-08-2012
    Location
    Kyle, TX, USA
    MS-Off Ver
    Excel 97, 2003, 2007, 2010
    Posts
    3

    Question Click a button - pass some information - How To?

    This should be simple... but I'm missing something.

    Imagine two buttons on a form.

    When you click either button you want the same MACRO to run, but do slightly different tasks. (Different range, different color, etc.)
    You install a variable called "mydata" and if it has a value of "1" it will behave one way, if "2" it will behave another.

    For now... let's just put this value into cell "B3"... just so I can see that the data is actually passed.

    Please Login or Register  to view this content.
    I thought that I could just change the routine to

    Please Login or Register  to view this content.
    But if I do... when I try to assign it to a button...

    BUTTON 1 would call DO_SOMETHING_ELSE("1")
    ...OR...
    BUTTON 2 would call DO_SOMETHING_ELSE("2")

    It say's it's too complex.

    I can call WORKBOOK!DO_SOMETHING just fine... but if I add the data field... FAIL.

    So...

    How do I call DO_SOMETHING and pass the variable... or call DO_SOMETHING_ELSE(data) ?

    Thanks,
    Jerry

  2. #2
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: Click a button - pass some information - How To?

    something like this.....un-tested

    Please Login or Register  to view this content.
    if you have more button you might consider switching to a CASE/SELECT construct....
    Ernest

    Please consider adding a * if I helped

    Nothing drives me crazy - I'm always close enough to walk....

  3. #3
    Registered User
    Join Date
    11-08-2012
    Location
    Kyle, TX, USA
    MS-Off Ver
    Excel 97, 2003, 2007, 2010
    Posts
    3

    Re: Click a button - pass some information - How To?

    Right at the time you were sending a reply... I tried this... it worked... not elegant... but it worked.

    Please Login or Register  to view this content.
    So it looks like that's the way to do it.
    Thanks for the help!!

    Jerry
    Last edited by Askjerry; 01-23-2014 at 05:36 PM. Reason: Clean up display

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Click a button - pass some information - How To?

    I think you will find this to be a better technique, not related to your original question. No need to Select and then operate on ActiveCell.

    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ 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] click on a color button and after button click it will color entire row of cell you click
    By swade730 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-11-2014, 06:06 PM
  2. [SOLVED] Can you pass a button name to a macro?
    By brucemc777 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-28-2013, 03:05 PM
  3. how can ListIndex can be pass when botton click
    By jay11 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-23-2010, 06:25 AM
  4. Call button click event from a button on anther sheet
    By ajaykgarg in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-25-2010, 09:27 AM
  5. [SOLVED] [SOLVED] Create floating button based on button click in menu
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-12-2005, 02:05 PM

Tags for this Thread

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