+ Reply to Thread
Results 1 to 2 of 2

how to assign value to button and use it as variable in a macro

  1. #1
    Valued Forum Contributor luv2glyd's Avatar
    Join Date
    07-13-2008
    Location
    Seattle, WA, US
    MS-Off Ver
    Excel 2010
    Posts
    679

    how to assign value to button and use it as variable in a macro

    I'd like to have several buttons in a sheet that have individual variables assigned to them, that are used by the same macro. To give an example, let's say I have a macro that inputs a value into cell A1 as soon as I press a button. What I'd like to do is if I press button1, cell A1 gets a 1 in it, if I press button2, if I press button3, cell A1 gets a 3 in it and so on. This is just an example, as the real code is more lengthy, but in summary what I'm after is having a single macro which gets activated by a button and uses a variable assigned to that button, rather then having a macro assigned to button1, then a separate macro assigned to button2, and so on... So in example above, value of 1 is assigned to button1, 2 to button2 and so on. Is this possible? If so, what's the simplest way to do it?

    Thank you.
    You either quit or become really good at it. There are no other choices.

  2. #2
    Forum Contributor
    Join Date
    07-27-2012
    Location
    California, USA
    MS-Off Ver
    Excel 2003
    Posts
    198

    Re: how to assign value to button and use it as variable in a macro

    Will this work for you?
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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