+ Reply to Thread
Results 1 to 11 of 11

Extract 2 elements from HTML table (code + site provided)

  1. #1
    Registered User
    Join Date
    08-20-2014
    Location
    Toronto, Canada
    MS-Off Ver
    2013
    Posts
    95

    Question Extract 2 elements from HTML table (code + site provided)

    I am trying to extract the LEI and name from the following website:

    https://www.gmeiutility.org/search.jsp

    As an example, search for "Pafco Insurance Company".

    The first column contains LEI and the second contains legal name. I want to copy these first two values from the two columns and paste them into my sheet.

    How would I do that?

    This is what I have so far.

    Please Login or Register  to view this content.
    Two other questions (more out of interest than necessity):

    1. What's the best way to handle "waiting"? I have
    Please Login or Register  to view this content.
    but that doesn't feel too elegant.

    2. Is there a way to do this without actually opening internet explorer?
    Last edited by efarkouh; 09-21-2016 at 03:05 PM.

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

    Re: Extract 2 elements from HTML table (code + site provided)

    Do you want to get all the data on the table or first two rows?

  3. #3
    Registered User
    Join Date
    08-20-2014
    Location
    Toronto, Canada
    MS-Off Ver
    2013
    Posts
    95

    Re: Extract 2 elements from HTML table (code + site provided)

    Just the first value from each of the first two columns. Only the first value in LEI and the first value in Legal Name.

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

    Re: Extract 2 elements from HTML table (code + site provided)

    I have attached both codes, one for all data and second one just the first two.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    08-20-2014
    Location
    Toronto, Canada
    MS-Off Ver
    2013
    Posts
    95

    Re: Extract 2 elements from HTML table (code + site provided)

    Thanks a ton for this.

    I'm not familiar with Option Explicit. So here's my version of the code for anyone who needs it.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    I'll be testing for a bit before I mark as solved.
    Last edited by efarkouh; 09-21-2016 at 03:49 PM.

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

    Re: Extract 2 elements from HTML table (code + site provided)

    Option Explicit forces you to declare all your variables. It is not only a good coding practice, but also saves you lots of time by spotting typos.
    I did not pay attention to it while I was learning, but now I can not imagine writing a code with out it.

  7. #7
    Registered User
    Join Date
    08-20-2014
    Location
    Toronto, Canada
    MS-Off Ver
    2013
    Posts
    95

    Re: Extract 2 elements from HTML table (code + site provided)

    Quote Originally Posted by AB33 View Post
    Option Explicit forces you to declare all your variables. It is not only a good coding practice, but also saves you lots of time by spotting typos.
    I did not pay attention to it while I was learning, but now I can not imagine writing a code with out it.
    That clear it up. Thanks again. I'll try to incorporate that into my code more often then.

    I'm at home now, but before I left work I was having an issue when I was try to run this in a loop where it would give me a "Permission Denied" error. The error came up when it tried to change the name in the search bar to the next legal name. I'll have more detail about the issue when I get to work tomorrow, but it would be great if you had any idea what this could be.

  8. #8
    Registered User
    Join Date
    08-20-2014
    Location
    Toronto, Canada
    MS-Off Ver
    2013
    Posts
    95

    Re: Extract 2 elements from HTML table (code + site provided)

    Since I couldn't get it to loop, I tried to do each one by using selection.value in the search_field. But I ran into another issue, which is closing each instance of ie. ie.Quit doesn't work. Is there any other way to do that?

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

    Re: Extract 2 elements from HTML table (code + site provided)

    Yes, you can loop.
    Attach a sample excel book with values you need to search in column A. I presume these are company names.

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

    Re: Extract 2 elements from HTML table (code + site provided)

    I used the company names in column starting from A2.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    08-20-2014
    Location
    Toronto, Canada
    MS-Off Ver
    2013
    Posts
    95

    Re: Extract 2 elements from HTML table (code + site provided)

    Thanks a lot for this. It just made my life a ton easier.

+ 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. Extract html table data from specifi table only
    By hcyeap in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-26-2016, 02:34 PM
  2. Extract HTML code from a web page
    By SlavOK400 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-12-2016, 09:05 PM
  3. Extract text from html code
    By deglass in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-07-2015, 10:12 PM
  4. VBA to Extract Data from HTML Code
    By Juggler_IN in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-19-2014, 12:44 PM
  5. Grab javascript / html table from a site
    By JasperD in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-31-2014, 10:06 AM
  6. How to extract HTML elements?
    By babyboy808 in forum Excel General
    Replies: 1
    Last Post: 07-22-2014, 04:24 AM
  7. Resources for Using VBA to Manipulate Silverlight Elements like HTML Elements
    By linear_db in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-16-2013, 04:43 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