+ Reply to Thread
Results 1 to 5 of 5

macro help: click button to update value of primary cell

  1. #1
    Registered User
    Join Date
    11-19-2009
    Location
    Lubbock, TX
    MS-Off Ver
    Excel 2007
    Posts
    3

    macro help: click button to update value of primary cell

    Hello all,

    I was not able to locate what I need in anything already posted, so here goes...
    I am wanting to create macros (but don't know VBA) to assign to buttons such that clicking the button will change the value of a primary cell, but not below 0. Some details:
    * primary cell will be G7 on worksheet 1, with a starting value of 25
    * one button on each of the other 4 worksheets in the same workbook, with values of -3, -1, +1, and +3 (respectively)
    * clicking a button will add/subtract the button's value from G7 (worksheet 1)
    * the value of G7 can not fall below 0 (value of 0 is okay): if clicking a button should cause G7 to go negative, a message appears "Not enough points" and there is no change to the value of G7

    Not sure if this is possible, but I'm confident that this forum can find the answer if it is. Thank you in advance for your time and assistance.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: macro help: click button to update value of primary cell

    Hi,

    You need to use write a macro. Go to the Visual Basic Environment, Insert a Module, and in the Module copy the following procedure.

    Please Login or Register  to view this content.
    Now right click each button on sheets 2 to 5 (or create one button and copy it), and assign it to the UpdateG7 macro.

    HTH
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    11-19-2009
    Location
    Lubbock, TX
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: macro help: click button to update value of primary cell

    Thank you so much! I'll plug it in as soon as I have access to the spreadsheet, then I'll let you know.

  4. #4
    Registered User
    Join Date
    11-19-2009
    Location
    Lubbock, TX
    MS-Off Ver
    Excel 2007
    Posts
    3

    Thumbs up Re: macro help: click button to update value of primary cell

    works beautifully - thanks again.

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: macro help: click button to update value of primary cell

    Quote Originally Posted by uthminister View Post
    works beautifully - thanks again.
    My pleasure.

    Cheers

+ 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