+ Reply to Thread
Results 1 to 19 of 19

Query Multiple Web Pages> Sort For Specific Criteria > Save Lists of Sort in txt files

  1. #1
    Registered User
    Join Date
    11-16-2012
    Location
    Oklahoma
    MS-Off Ver
    Excel 2003
    Posts
    31

    Post Query Multiple Web Pages> Sort For Specific Criteria > Save Lists of Sort in txt files

    Hello everyone,
    I am looking for some help in getting a macro to query multiple webpages and then sort that data to see if three file types are within the table. From there I want the file types to be separated into 3 lists that save to 3 txt files.

    For example: This is the base url for the site. http://www.pangaeadata.com/OCC_Files...api=3507124329
    I want the 10 digits on the end to change according to a list I have with ~1000 different sets of numbers.

    The table for the URL looks like this:

    http://www.pangaeadata.com/OCC_Files...api=3507124329

    The ten digit number references an oil well. Which is located at the top of the table. I want to search all my wells and see what forms are available for them in excel.
    Basically, I am wanting a query to search for all wells that have a 1000/1001A/1002A form filed and if it has one, I want it to put that API number into a list with others with 1000/1001A/1002A forms filed and save a txt file for each different form filed.
    If possible I would like a to have a hierarchy where if a 1002A form has been filed it won't look for the other two files. ex. 1002A>1001A>1000 (if 1002A is available I want that API number saved, if there is no 1002A yet, then I want the 1001A API number saved, and so on.) I understand how to do the web query and the txt file save, but I want it to update with the latest info weekly and automatically give me a list.

    Any help is very much appreciated. Im interning right now, so if I can get this to work I will look real good. Plz help.

  2. #2
    Registered User
    Join Date
    11-16-2012
    Location
    Oklahoma
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: Query Multiple Web Pages> Sort For Specific Criteria > Save Lists of Sort in txt files

    Bump* any help folks?

  3. #3
    Registered User
    Join Date
    11-16-2012
    Location
    Oklahoma
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: Query Multiple Web Pages> Sort For Specific Criteria > Save Lists of Sort in txt files

    Can anyone give me a starting point? Trying to understand how to do this by Monday so I can get the spreadsheet running this coming week.

  4. #4
    Registered User
    Join Date
    11-16-2012
    Location
    Oklahoma
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: Query Multiple Web Pages> Sort For Specific Criteria > Save Lists of Sort in txt files

    Bump* really need help folks. Can't figure out how to query a list of websites. Have the save list to files part down, but can't get the macro for sorting to work right and I have resorted to making a web query for each site one by one. Which is not ideal when I am dealing with thousands of sites. Help please!!!'

  5. #5
    Registered User
    Join Date
    11-16-2012
    Location
    Oklahoma
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: Query Multiple Web Pages> Sort For Specific Criteria > Save Lists of Sort in txt files

    bump up the jam?

  6. #6
    Registered User
    Join Date
    11-16-2012
    Location
    Oklahoma
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: Query Multiple Web Pages> Sort For Specific Criteria > Save Lists of Sort in txt files

    persistence is key *bump*

  7. #7
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Query Multiple Web Pages> Sort For Specific Criteria > Save Lists of Sort in txt files

    You are asking for quite a lot there, but hopefully the following should get you started.

    A web query is the simplest way of retrieving data from the web, but not the fastest. Start by recording a macro which does a web query for one of the URLs. Use a separate sheet for this web query. VBA code can be written to use the same web query (QueryTable) for each API number in turn, modifying its Connection property and calling the Refresh method to retrieve the web data for that API.

    For the hierarchical searching of form numbers you could call the Find method of the Range object in a loop to search for each form number in the order you have given and exit the loop when the first one is found.

    "but I want it to update with the latest info weekly and automatically give me a list."

    You need to explain this more. For the first run, the code would retrieve the data for all API numbers and create the 3 text files as specified, but what data should be updated weekly?
    Post responsibly. Search for excelforum.com

  8. #8
    Registered User
    Join Date
    11-16-2012
    Location
    Oklahoma
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: Query Multiple Web Pages> Sort For Specific Criteria > Save Lists of Sort in txt files

    Thanks for the starting point. I realize now how complicated it is after looking around. I'll give it a run and post my results. Just wasn't sure how easy it was to loop that query from a list. Should I look up how to use a query table in this forum? To answer the question about updating. The form numbers indicates what stage the well is in the process if completion. You first get a permit(1000) and completion is 1002A. These forms can come out weeks/months after each other. I would like an update of each well in the process weekly and with the three separate lists I will plot points on a map to show me where people are and in what stage they are in. I appreciate the help. I'll get back as soon as I can.

  9. #9
    Registered User
    Join Date
    11-16-2012
    Location
    Oklahoma
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: Query Multiple Web Pages> Sort For Specific Criteria > Save Lists of Sort in txt files

    Ok. So i got the web query to query all the numbers I want and got it to pull some of the data i wanted. Figured out that the website sorts the files randomly each time I query it. So the order I get the data in is different everytime. I initially tried to pull the form# (B4) from the first line of the table and the date (G4) from that same row, but now i need to have it sort or find the file # and if copy it and the date it corresponds to. Tried a few different routes, but getting errors. Ill post the code I have so far.

    Please Login or Register  to view this content.
    This is the format I have the data being pulled to a worksheet the way I want it.
    1.jpg
    This is the format the data is queried into excel
    2.jpg


    If I could get some help on pulling the dates for the files in an hierarchy (I want form#1002A(Col B) date first (Col G), if form#1002A doesn't exist then I want the form#1001A date, and if form#1001A/1002A doesnt exist yet I want the date for form#1000)
    Last edited by Tlandress; 12-03-2012 at 05:50 PM.

  10. #10
    Registered User
    Join Date
    11-16-2012
    Location
    Oklahoma
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: Query Multiple Web Pages> Sort For Specific Criteria > Save Lists of Sort in txt files

    *bump* just seein if anyone can help me before i head out today

  11. #11
    Registered User
    Join Date
    11-16-2012
    Location
    Oklahoma
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: Query Multiple Web Pages> Sort For Specific Criteria > Save Lists of Sort in txt files

    bump. still stuck on getting the info to sort the way i want it
    . please help.

  12. #12
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Query Multiple Web Pages> Sort For Specific Criteria > Save Lists of Sort in txt files

    Is it possible that a well won't even have a 1000 form filed? If so what would you want returning?

    Could you also post a sample workbook with a few urls in please?

  13. #13
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Query Multiple Web Pages> Sort For Specific Criteria > Save Lists of Sort in txt files

    Ok, give this a whirl. I noticed in your screenshots that you have the full url in your workbook, so this codes uses that rather than the well ID

    Please Login or Register  to view this content.
    To use this, put it in a standard module, the function returns an array so should be used like this:

    Assuming the url is in A1
    Select B1 and C1, enter the formula:
    PHP Code: 
    =GetWellData(A1
    Hold Control + Shift + Enter instead of just pressing enter

    The Latest form will be placed into B1 and the date into C1

    You can then copy this formula down

  14. #14
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Query Multiple Web Pages> Sort For Specific Criteria > Save Lists of Sort in txt files

    You'll need to hit Control + Alt + F9 to refresh all the formulas whenever you want to update

  15. #15
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Query Multiple Web Pages> Sort For Specific Criteria > Save Lists of Sort in txt files

    Thanks for the Rep, did this do what you want?

  16. #16
    Registered User
    Join Date
    11-16-2012
    Location
    Oklahoma
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: Query Multiple Web Pages> Sort For Specific Criteria > Save Lists of Sort in txt files

    Still trying to get it to work. I haven't had a good moment to look through it though. Finals week at school so trying to get that done first. Ill try it as soon as possible and let you know.

  17. #17
    Registered User
    Join Date
    11-16-2012
    Location
    Oklahoma
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: Query Multiple Web Pages> Sort For Specific Criteria > Save Lists of Sort in txt files

    Just finally got around to testing your code. Worked flawlessly. Thanks again for all the help. One last thing. How would I add the ability to export API# (the number at the end of the web address) into 3 separate text files of the 3 different files. Basically just want to make a list of APIs with 1000 files, 1001A files and the 1002A files separately. I have done it before but not sure how to add it to the code you gave me.

  18. #18
    Registered User
    Join Date
    11-16-2012
    Location
    Oklahoma
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: Query Multiple Web Pages> Sort For Specific Criteria > Save Lists of Sort in txt files

    I also just realized that I need to somehow post the most recent file. Didn't realize that there would be multiple files of on each well. Is there a way of sorting for the most recent date?
    Last edited by Tlandress; 01-10-2013 at 03:06 PM.

  19. #19
    Registered User
    Join Date
    11-16-2012
    Location
    Oklahoma
    MS-Off Ver
    Excel 2003
    Posts
    31

    Re: Query Multiple Web Pages> Sort For Specific Criteria > Save Lists of Sort in txt files

    Bump* bump* bump* bump* .........bump*

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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