+ Reply to Thread
Results 1 to 6 of 6

Need a macro to loop through a drop down box

  1. #1
    Registered User
    Join Date
    07-12-2011
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2010
    Posts
    3

    Need a macro to loop through a drop down box

    Hello, I'm new to progamming as you'll probably be able to notice with my code so please bear with me.

    I am trying to use a macro to run a pricing comparison and to copy each price over to another worksheet so I can view all of them in one spot.

    There are 2 companies, A and P, where company P has 14 possible rates depending on what selection is made in cell F23 on the 'Quote' Tab. I set up a macro to move the chosen coverages along with company A premium to the 'Comparison' Tab but am having problems when it comes to quoting and recording all of company P's premiums.

    I set up a macro to loop, which it seems to do, but what I want the macro to do is to start with the first item in the drop down box, A1, (which as an FYI this cell uses the list from AD7:AD20), move company P's rates over to the 'Comparison' Tab and drop them into the corresponding cells in column E. Then go back and change the drop down box to B1, move those rates to column F in the 'Comparison' Tab and so on - all the way to the final selection of Y1 in column R.

    Here is the macro and part of my copy/paste code (which is probably the long way of doing it) that I set up to move company P's premiums over. Does anyone have any insight as to how I can add code to loop through the drop down box and record each of the specific premiums at the same time?

    Please Login or Register  to view this content.
    (I attached a spreadsheet with all the code if it helps. The loop code is under Module 2, named Tier A1 macro)
    Attached Files Attached Files
    Last edited by WC_500; 07-13-2011 at 12:12 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Need a macro to loop through a drop down box

    I would update your macros like so:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    07-12-2011
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Need a macro to loop through a drop down box

    Wow, that is great. You just saved me a bunch of time

    I left the code I already had in place for the Quote_All_Tiers macro because I noticed if I put in the code that you suggested in, it doesn't move the selections from the Quote Tab that should go to the Comparison Tab to columns C and D. It just overlays them onto the Quote screen. Maybe something is reversed in the code or a reference is missing?

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Need a macro to loop through a drop down box

    There's no need to guess, just look at the code... it absolutely puts the values from various cells in the Quoter page into the cells in columns C:D of the Comparisons page. And it does it without all the inefficient selecting and switching and copy/pasting.
    Please Login or Register  to view this content.
    This line of code says "make the value of C17:C18 on the Comparisons page the same values as L7:L8 from the Quoter page."

    When I run that line of code I see the value transfer in, you don't?

    Clear the cells on the Quote page, then use the F8 key in the VBeditor to run that macro one line at time, check the Comparisons sheet after each command, you'll see the values coming in.

  5. #5
    Registered User
    Join Date
    07-12-2011
    Location
    Minneapolis, MN
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Need a macro to loop through a drop down box

    Oh, you're right sorry about that. Thanks for the tip on using F8.

    After running through it I saw that the problem was the Formatting Macro. Turns out it formatted the Quote Tab rather than the Comparisons Tab. So I made sure to reference the Compariston tab and everything works just fine now.

    Thanks so much for the help!

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Need a macro to loop through a drop down box

    Glad to help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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