+ Reply to Thread
Results 1 to 5 of 5

Running Calculations Based on Selections from a Drop Down

  1. #1
    Registered User
    Join Date
    05-14-2020
    Location
    Washington State
    MS-Off Ver
    2016
    Posts
    61

    Running Calculations Based on Selections from a Drop Down

    Hi Everyone,

    I am trying to create a macro that will do a simple calculation by subtracting the values from two different cells, each taken from a different sheet, and then add the value from a third cell to come up with a final answer. What's making this so challenging is that I want to incorporate a drop down list to determine the first value to be considered in the equation. There are (3) different values in a column on a separate sheet that correspond to the values in the drop down list. When I select one of the list items I want the macro to choose the corresponding value for the first value of the equation. For example, say my list allows me to select 8" slabs, 12" slabs or 12.5" slabs, these items correspond to 8, 12 and 12.5 on the other sheet. So, if I pick 8" slabs I want the macro to pick 8 as the first variable.

    I eventually want to add some additional complexity by having the macro chose the second value which is subtracted from the value above. This second variable also comes from a list which will correspond to a cell value on a separate sheet. I think if I can get the first part to work I may be able to figure out this second part, but I'm uncertain how to incorporate the drop down list to begin with. I would appreciate any help offered on this.

    Below is a simple macro I wrote to test the basic idea (I'm sure there's a more efficient way of doing this). If this code can be modified to achieve my goal how would I go about modifying it?

    In summary, the basic equation is Y = A - B + C. A is chosen from a list of three options that correspond to a selection from the drop down list. B is chosen from another column on a third sheet which corresponds to a value found in a cell on the first sheet and then C is simply a value manually imputed on the first sheet. Hope this all makes sense. Again, I appreciate any help you can offer on this.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by Proj_Eng; 05-29-2020 at 06:49 PM. Reason: I forgot to add the sample workbook

  2. #2
    Registered User
    Join Date
    05-29-2020
    Location
    Indiana, USA
    MS-Off Ver
    M365
    Posts
    27

    Post Re: Running Calculations Based on Selections from a Drop Down

    Greetings!
    It'd be easy just to use a formula to finish the calculations.
    A=
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Looks up input
    From the table on Data1
    Returns with that value

    Nest it in the rest of your formula for Y
    Y=A-B+C
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Example attached on DATA1
    Last edited by Kirkules; 05-29-2020 at 11:05 PM. Reason: Attached example

  3. #3
    Valued Forum Contributor
    Join Date
    06-22-2018
    Location
    Blackpool, England
    MS-Off Ver
    2019
    Posts
    408

    Re: Running Calculations Based on Selections from a Drop Down

    I was going to make the same suggestion as Kirkules, above. I'd personally use a combination of INDEX and MATCH; does the same thing but can be more flexible. This will give you figure "A"
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Figure "B" is simply Data2!A4 and "C" is Input!K1

    This gives you the formula for F32 on the print sheet as
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Of course, you can adapt the INDEX/MATCH formula to fit other dropdowns or options in the calculation and substitute "B" and/or "C" accordingly

    Tim
    Never stop learning!
    <--- please consider *-ing !

  4. #4
    Registered User
    Join Date
    01-15-2020
    Location
    somewhere
    MS-Off Ver
    2016
    Posts
    30

    Re: Running Calculations Based on Selections from a Drop Down

    You could also make a userform with a dropdown. That may be easier.

  5. #5
    Registered User
    Join Date
    05-14-2020
    Location
    Washington State
    MS-Off Ver
    2016
    Posts
    61

    Re: Running Calculations Based on Selections from a Drop Down

    I had a co-worker suggest the same thing. I was not familiar with LOOKUP Functions, so hadn't thought of that. It worked great! Thanks for the help!

+ 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. Replies: 8
    Last Post: 03-03-2015, 06:58 AM
  2. Replies: 1
    Last Post: 08-21-2014, 11:23 AM
  3. [SOLVED] Populate data based on several drop down selections
    By NerdALRT in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-25-2014, 03:42 PM
  4. 3 dependant drop down lists & one autofill based on those selections
    By claire_wilson in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-17-2013, 06:59 PM
  5. Filter data in one tab based on drop down selections in a different tab
    By ragonef in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-15-2012, 09:27 AM
  6. Drop down lists based on selections in previous list
    By justindbutler87 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-12-2011, 03:27 PM
  7. [SOLVED] Dynamic charting based on two drop down selections - help
    By TalResha in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 01-07-2011, 06:52 AM

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