+ Reply to Thread
Results 1 to 4 of 4

VBA referencing drop down menu, and calulating based on choice in menu

  1. #1
    Registered User
    Join Date
    08-19-2013
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Post VBA referencing drop down menu, and calulating based on choice in menu

    I am new to macros/VBA so bear with me.

    I have made two drop down menus that will influence which calculations to perform.

    for simplicity,
    Drop down 1 has options: "one" or "two"
    Drop down 2 has options: "summer" or "fall"

    So if the user chooses "one", and "summer" then after the button click, it will preform one set of calculations and display the results in a column of cells (D).
    different combinations of the drop downs will calculate using other formulas.

    So how can I have the code read the drop down string, then based on what it is, execute the calculations and display them in column D.


    for ex.

    If Dropdown 1 = one and Dropdown 2 = summer Then
    D1 = A1+A2
    D2 = A3/A4

    ElseIf Dropdown 1 = two and Dropdown 2 = fall Then
    D1 = A1-A2
    D2 = A3*A4
    ....
    ect

    Thanks

  2. #2
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: VBA referencing drop down menu, and calulating based on choice in menu

    Hi,

    Are the drop-down lists ActiveX objects, or are they data validation lists within a cell?

    Could you please upload an example workbook so that I may look at your code in context?

    Thanks

  3. #3
    Registered User
    Join Date
    08-19-2013
    Location
    San Diego, CA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: VBA referencing drop down menu, and calulating based on choice in menu

    Capture.PNGCapture2.PNG

    So here is a very simplified version. The drop downs are in text validation. The two drop down options are resi, and smooth. I would like the calculations to change in cell B7 as shown in the pictures.

    I did come up with a work around to this problem by using VLOOKUP and 1's and 0's. B7 had both equations in it and each equation was multiplied by a hidden set of operator cells, which change between a 1 and a 0 depending on the drop down menu selection.

    so if resi is selcected, D1 = 0 and D2 = 1, so the resi equation is multiplied by D2 and the smooth equation by D1.

    Seems to be working?

  4. #4
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: VBA referencing drop down menu, and calulating based on choice in menu

    Hi again,

    Try this formula in cell B7 (this should work for both "smooth" and "resi"):
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    or alternatively use:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Both of these formulae will produce the same output, it is simply up to you which one you choose to use.

    Hope this helps

    P.S. If this is the solution that you were after, please don't forget to mark this thread as solved and click on the * next to my post to say thanks

+ 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. [SOLVED] Excel 2007 : new drop down menu based on dropdown menu in previous cell
    By martinpols in forum Excel General
    Replies: 3
    Last Post: 04-30-2012, 02:33 AM
  2. Drop down menu, need a choice added
    By shanshine in forum Excel General
    Replies: 4
    Last Post: 09-28-2011, 03:37 PM
  3. Replies: 1
    Last Post: 03-20-2009, 08:05 PM
  4. Updating graphs based on choice in drop-down menu:
    By tim.maciejewski in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 03-02-2009, 06:09 PM
  5. drop down menu that will fill in some other firlds based on choice
    By soundengineer in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-18-2007, 12:13 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