+ Reply to Thread
Results 1 to 4 of 4

Excel VBA to select next item on the drop-down list and loop until the end is reached

  1. #1
    Registered User
    Join Date
    06-30-2017
    Location
    Mumbai, India
    MS-Off Ver
    MS Office 2007
    Posts
    5

    Excel VBA to select next item on the drop-down list and loop until the end is reached

    Files
    1. DataSource File [ This file has Various Code/ID data]
    2. ImportData File

    What I have:

    1. I have a simple web query to get specific data from website, with data refresh enabled.
    2. Thus basic structure of WebQuery is
    • a) Look for value in Cell B1, B2 & B3 and refresh and display data in Cell/Range A7 onwards
    • b) B1 & B2 is Drop-Down Validation List from DataSource File.
    • c) B3 has Vlookup formula based on value of cell B1
    • d) C1 has Vlookup formula based on value of cell B1


    B1 has 90+ values, B2 has 7+ values to choose from the Drop-Down-List.


    What I would like to have is then:-

    1. Loop through the entire list of value in Cell B2 [Thus data is imported for 7+ B2 values with B1 & B3 remains same]
    2. The result of web query runs and gets the data.
    3. Save the WebQuery-result[Step2] of each value of Cell B2 in Separate Workbook in separate sheet for 7+ values
    4. Name the newly created Workbook the name in the C1 & the individual sheet will be based on value in Cell B2
    5. Then go to the next value in Cell B1, and start the entire process all over again until the end of B1 is reached.

    I know the computer might slow down if this is done in one go, however i can edit the source file[DataSource File], to process 10-15 values of B1


    Image for Ref:

    ExcelForum_Vba Query.png


    Thanks in advance.

  2. #2
    Registered User
    Join Date
    06-30-2017
    Location
    Mumbai, India
    MS-Off Ver
    MS Office 2007
    Posts
    5

    Re: Excel VBA to select next item on the drop-down list and loop until the end is reached

    Here is the Web Query:

    Can i use this in the VBA for main question/problem

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-30-2017
    Location
    Mumbai, India
    MS-Off Ver
    MS Office 2007
    Posts
    5

    Re: Excel VBA to select next item on the drop-down list and loop until the end is reached

    Some clarification and this can help everyone.
    • 1. VBA Code to Select 1st Value of B1
    • 2. VBA Code to Select 1st Value of B2
    • 3. Then run the WebQuery
    • 4. Save the output of the WebQuery to Separate Workbook with Worksheet name as that of the value in Cell B2

    Then
    • 5. Now VBA Code to select 2nd Value of Cell B2
    • 6. Repeat Steps 3 & 4 [to select next value..2nd/3rd etc.], till the Last Value of B2 is reached.
    • 7. When End Value of B2 is reached, Select Next Value of Cell B1.
    • 8. Repeat the steps from 2 to 7 till the End of B1 is reached.

    Another possibility is that Create Separate Workbook for each values of B2 and combine at end into Single Workbook when end of B2 is reached, with name of WorkBook that of Cell C1
    Last edited by rpdDrp; 06-30-2017 at 07:44 AM. Reason: Colour Coded

  4. #4
    Registered User
    Join Date
    06-30-2017
    Location
    Mumbai, India
    MS-Off Ver
    MS Office 2007
    Posts
    5

    Re: Excel VBA to select next item on the drop-down list and loop until the end is reached

    What i did is taken the data from DataSource to new sheet called source and naming respective tables as "mainID", subIDType", "coreID" etc.

    I managed to come up with this code. This is just a initial loop which will select values from named range

    Please Login or Register  to view this content.
    Now I want the web-query to run when values are set as per above.

+ 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. how to auto select drop list item when closing file?
    By Imran Magsi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-14-2016, 02:39 AM
  2. Replies: 5
    Last Post: 04-11-2014, 03:13 PM
  3. Select an item from drop down list and auto fill in next working date
    By pjlau in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-23-2012, 12:49 AM
  4. How to create drop down list in Excel where each list item is based on two columns?
    By matkiros in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-11-2012, 08:50 AM
  5. Replies: 3
    Last Post: 11-15-2008, 09:49 PM
  6. Select item in drop-down list in Vbasic
    By ramza in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-13-2006, 05:59 AM
  7. Replies: 5
    Last Post: 10-27-2005, 01:55 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