+ Reply to Thread
Results 1 to 8 of 8

Macro to extract data from a URL

  1. #1
    Registered User
    Join Date
    10-28-2010
    Location
    Denmark, Europe
    MS-Off Ver
    Excel 2010
    Posts
    62

    Macro to extract data from a URL

    Hi

    I'm very much in need of some help. I'm trying - with no luck - to write a macro to do some data extraction for me. I have a column (B2:B1686) with URLs from which I would like to extract data to my work sheet.

    here is an example of a url: http://ieee-emf.com/viewstudy.cfm?ID=1

    What I specifically want to do is in 11 columns, say, from E to O to copy the content of the table in midle of the website.

    So that I'll get the values from the table copied to the row corresponding to the specific URL in my worksheet.


    the url ID Number Study Type Model Details Findings Status Principal Investigator Funding Agency Country References Comments
    http://ieee-emf.com/viewstudy.cfm?ID=1 1 In Vivo some txt some txt etc etc etc etc etc etc often empty, but sometimes with some txt
    .. .. .. .. .. .. .. .. .. .. .. ..


    Thanks in advance
    Jaco

  2. #2
    Valued Forum Contributor
    Join Date
    07-07-2014
    Location
    Washington DC
    MS-Off Ver
    2007
    Posts
    1,047

    Re: Macro to extract data from a URL

    Not sure if you necessarily need a macro, unless you have tons of websites you're doing this for. Using the Data > From web function I was able to easily populate the attached table, which can be reformatted for your preferences.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    10-28-2010
    Location
    Denmark, Europe
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Macro to extract data from a URL

    Thanks

    There are 1685 webside, so doing it manually would take a while + I would like to have the data in a row instead of a column.

  4. #4
    Registered User
    Join Date
    10-28-2010
    Location
    Denmark, Europe
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Macro to extract data from a URL

    I'm currently able to get excel to open the websides on at a time with the InternetExplorer.Application and then .Navigate
    I asume I'll have to use the getElementsByTagName to go to the right cells in the url's table, but how to do that at how to get it copied to the different columns in the corresponding Url's row in my data sheet, that I not sure how to do.

    Jacob

  5. #5
    Registered User
    Join Date
    10-28-2010
    Location
    Denmark, Europe
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Macro to extract data from a URL

    No one? I would really love to find a solution. What's causing me the most trouble is finding out how to get the code to find the right cells in the table? Since the websites seems to have more than one table.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Macro to extract data from a URL

    Hello Flabbergaster,

    The attached workbook contains the macros show below. I have added a button to the worksheet named "Extract Data" that will run the macro.

    The URLs are in column "B" starting at row 2 and the extracted data is placed in the same row as the URL in columns "E:O".

    Module1 - Macros to Extract Web Table Data
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  7. #7
    Registered User
    Join Date
    10-28-2010
    Location
    Denmark, Europe
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Macro to extract data from a URL

    Wow..
    Works like a charm.

    Besides solving my problem, this code also gives me something to study and learn from

    Thanks a lot!

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Macro to extract data from a URL

    Hello Flabbergaster,

    You're welcome.

+ 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] Pausing A Macro (allow user to extract data) aAnd Resume Macro
    By jbumps in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2013, 01:59 PM
  2. macro to extract data
    By kt090678 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-10-2011, 04:55 PM
  3. Macro to extract Data
    By dandavis1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-07-2008, 07:33 AM
  4. How to Extract Data using Macro?
    By da80th in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-19-2007, 06:39 AM
  5. Macro to extract data
    By Bill A in forum Excel General
    Replies: 3
    Last Post: 02-15-2006, 08:35 AM

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