+ Reply to Thread
Results 1 to 10 of 10

Using Excel and VBA to get API/Web Data with Multiple Queries

  1. #1
    Registered User
    Join Date
    09-01-2016
    Location
    England
    MS-Off Ver
    Office 2016
    Posts
    11

    Using Excel and VBA to get API/Web Data with Multiple Queries

    Hello all,

    This is my first post and I would be grateful if you could help me . I have spreadsheets with a large amount of data for querying. I am looking for each cell of data to be searched through API/Web Query and then resultant from that specific data to be extracted to Excel. What is the best way to go about searching multiple queries so to speak? Would it have to be combined with a macro which searches one cell after another?

    I appreciate your help.

    I have attached a sample file along with the URL which needs to be queried.

    Thank you!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Using Excel and VBA to get API/Web Data with Multiple Queries

    The API URL does not work, but companies house does.
    What sort of data do you wish to extract, is it just the name of the director or all his/her details?
    Last edited by AB33; 09-01-2016 at 11:28 AM.

  3. #3
    Registered User
    Join Date
    09-01-2016
    Location
    England
    MS-Off Ver
    Office 2016
    Posts
    11

    Re: Using Excel and VBA to get API/Web Data with Multiple Queries

    Thanks for the reply. Initially I was just looking for the name of the director, as I have a file to VLOOKUP the addresses.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Using Excel and VBA to get API/Web Data with Multiple Queries

    It works on the active sheet.
    Should have valid nos on column A and result will be on column B.
    Attached Files Attached Files

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

    Re: Using Excel and VBA to get API/Web Data with Multiple Queries

    If you're after something a bit more comprehensive, I made a VBA wrapper around the companies house API here: http://www.excelforum.com/tips-and-t...house-api.html it is in beta though so don't blame me if it breaks!

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Using Excel and VBA to get API/Web Data with Multiple Queries

    Hi Kyle,
    Glad you are in this thread.
    I know Classname does not work with late binding, but what I am not sure is, even with early binding, it only works with post method. Is this right? I am unable to get the text from H2 using a tagname, so I had to loop through each H2.
    What I am picking up is, there are no "hard and fast" rules with scrapping a web. It is trial and error.
    I will have a look at your API.
    Last edited by AB33; 09-01-2016 at 01:22 PM.

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

    Re: Using Excel and VBA to get API/Web Data with Multiple Queries

    Hi, no it works with post or get, the dom is completely unrelated to the request. There shouldn't be an issue with tagname, I'll have a look at your code when I'm in front of a computer

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Using Excel and VBA to get API/Web Data with Multiple Queries

    Hi Kyle,
    I managed to avoid a loop, but could easily error if the H2 is changed.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    09-01-2016
    Location
    England
    MS-Off Ver
    Office 2016
    Posts
    11

    Re: Using Excel and VBA to get API/Web Data with Multiple Queries

    Hi Kyle, thanks for linking me to this. I am a bit unfamiliar with how to use a VBA wrapper. Do I need to enter the functions into cells as formula to obtain the data?

    I also added positive reputation for you and AB33 for your help.
    Last edited by cfc06; 09-02-2016 at 08:25 AM.

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

    Re: Using Excel and VBA to get API/Web Data with Multiple Queries

    Quote Originally Posted by AB33 View Post
    Hi Kyle,
    I managed to avoid a loop, but could easily error if the H2 is changed.
    That's why it's better to use the api rather than web scraping. The api won't change, they're published to a specification

+ 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. excel multiple web queries deplete RAM
    By gapidianak in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 03-08-2016, 03:14 PM
  2. VBA To Create Multiple Queries When Data Varies
    By Excel4444 in forum Access Tables & Databases
    Replies: 3
    Last Post: 02-28-2016, 10:05 PM
  3. Replies: 0
    Last Post: 01-21-2013, 12:47 PM
  4. Embedded Access queries in Excel - if the database moves, how to update queries?
    By Paul_mcc in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-06-2012, 07:52 PM
  5. [SOLVED] Multiple Queries, Qry 2 based on Data Retrieved from Qry 1
    By Glenda in forum Excel General
    Replies: 0
    Last Post: 02-13-2006, 06:10 PM
  6. Importing multiple XML queries into Excel
    By Dave Bailey in forum Excel General
    Replies: 0
    Last Post: 10-07-2005, 05:05 AM
  7. [SOLVED] multiple queries in Excel
    By RickT in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-14-2005, 03:06 PM

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