Closed Thread
Results 1 to 3 of 3

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.

    WORKBOOK!DO_SOMETHING("1") for example... FAIL.


    So...

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

    So... if the user clicks BUTTON 1, the cell B3 will display "1"... if they click BUTTON 2, the cell should display "2".

    Can you help me?

    Thanks,
    Jerry

  2. #2
    Forum Contributor
    Join Date
    06-24-2013
    Location
    Berlin
    MS-Off Ver
    Excel 2007
    Posts
    188

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

    in the button code )use an active X button, put first a boolean like dim Isthisbutton1 as boolean, when you click on the button 1 it turns it to true and then call the sub in the other module. In that sub you specify the value that your variable should have if button 1 was clicked and else what value the variable should have if button 2 was clicked.

    Could you upload a sample of what you are trying to achieve, it may be easier to help you (make sure it's a XLSM)
    [Phil
    Last edited by mortphil; 01-23-2014 at 05:37 PM.

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

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

    Welcome to the Forum, unfortunately:

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.

    http://www.excelforum.com/excel-prog...on-how-to.html


    Thread Closed.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

Closed 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. Click a button - pass some information - How To?
    By Askjerry in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-23-2014, 05:44 PM
  3. [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
  4. 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
  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