+ Reply to Thread
Results 1 to 5 of 5

Buttons & Calculations

  1. #1
    Forum Contributor
    Join Date
    01-15-2015
    Location
    philippines
    MS-Off Ver
    Excel 365
    Posts
    116

    Buttons & Calculations

    Hi Guys,

    I have an excel workbook that uses an input box to ask for a number, then use that number as part of a formula. That formula is then finally put on a cell. There is just one button to run the macro for the input box to ask for a number.

    Now, I want to do something beyond that.

    Attached is a sample workbook that is modified for simplicity and for me to explain it better.

    The revised workbook now has three buttons and two different formulas.

    Formula 1: (A2+A3)/Rate1
    Formula 2: A2/(Rate2+A3)

    What the three buttons do are as follows:

    -First button: Tells the user to give a number between 101-200, then use that number as part of formula 1. And then put formula 1 in cell A5. (Another cell in a different sheet, which is in A2 and has nothing to do with the macro, has a formula on it that gives me a rate based on the value on A5. The higher the rate, the better.)

    -Second button: This is similar to the first button, but asks for a number between 1-100 instead and uses that number as part of formula 2. Formula 2 is then put on cell A5. (Cell A2 of the above mentioned, which is outside of the macro, does its thing again and gives me a rate. The higher, the better.)

    -Third button: The third button somewhat combines the first two buttons. What it should do should be in this sequence: It would ask for a first number input, then a second number input. Run the calculation using the first number input and formula 1. Run another calculation using the second number input and formula 2. Now, whichever formula gives me a higher rate in cell A2 of Sheet2 will be retained in A5.

    No need for an error handler if the user does not want to follow the number requirements for each of the buttons.
    Thanks guys.
    Attached Files Attached Files
    Last edited by richardking; 04-04-2019 at 12:35 AM.

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Buttons & Calculations

    Quote Originally Posted by richardking View Post
    ... a higher rate in cell B2 will be retained ...
    ???
    I think you mean 'A2' in sheet2 ?

  3. #3
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Buttons & Calculations

    Hi Richard,
    attached is a very simplistic solution to what I understand your requirements to be from the OP and correction?? from Porucha.

    I am very sure there are better methods to get the answer you need, I just took the simple way to demonstrate a possible solution. The variables storing the individual A5 results was just to allow me to see what was happening while stepping through the code, they could easily be removed.

    Hope this gets you further along your journey

    Cheers
    Attached Files Attached Files

    Cheers

    Jmac1947

    1. Please consider clicking on the * Add Reputation if you think this post has helped you
    2. Mark your thread as SOLVED when question is resolved

  4. #4
    Forum Contributor
    Join Date
    01-15-2015
    Location
    philippines
    MS-Off Ver
    Excel 365
    Posts
    116

    Re: Buttons & Calculations

    Thank you for pointing that out porucha vevrku, I had that corrected.
    Thank you jmac1947, it did the job. I just had to change the If result_1 <= result_2 Then into If result_1 > result_2 Then. Everything else is great.
    I truly appreciate it guys.
    Last edited by richardking; 04-04-2019 at 04:31 AM.

  5. #5
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Buttons & Calculations

    I see I have for you, after meat, mustard ... : ) ... but try:
    ... of course without error handling ... : )

    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)

Similar Threads

  1. Automatic calculations and maunal calculations Excel 2013
    By JCtheRULEr in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-12-2017, 05:09 AM
  2. Replies: 0
    Last Post: 03-10-2017, 01:53 PM
  3. Macros with buttons, spin buttons, scroll buttons, etc.
    By qqbbppdd in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-12-2013, 09:34 AM
  4. enable certain combo buttons based on user selected option buttons
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-20-2013, 06:43 AM
  5. How to insert and user of Buttons, Radio buttons, check boxes in excel sheet.
    By krishco in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-03-2013, 02:52 AM
  6. How can I insert multiple sets of option buttons (radio buttons) in Excel 2010?
    By mickwooduclan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-25-2013, 10:01 AM
  7. Replies: 0
    Last Post: 07-07-2012, 04:13 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