+ Reply to Thread
Results 1 to 7 of 7

VBA - extracting from websites

  1. #1
    Registered User
    Join Date
    04-19-2019
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Office 365
    Posts
    3

    VBA - extracting from websites

    Hi all,
    I’m trying to search webpages for words like “(Denmark)”, “(Sweden)” etc.
    Currently I have listed all the countries (Words) I’m searching for in Range("c1:HR1").
    Then all the words, which exists on the website, gets returned to me.

    The problem is now, I want to know in which order they appear on the website, or at least want to know, which country is first to be listed on the website.

    Example:
    Website:
    Sweden is number one in this category, Denmark is second, Finland is last.

    My VBA now, gives med the countries in alphabetic orders (Because of the order of my range): Denmark, Finland, Sweden.

    I want my VBA to give med Sweden, Denmark, Finland

    Hope you can help me 😊

  2. #2
    Registered User
    Join Date
    04-01-2019
    Location
    HK
    MS-Off Ver
    2010
    Posts
    32

    Re: VBA - extracting from websites

    Use elements index, start from 0:

    e.g. getElementsByTagName("country").Index + 1

  3. #3
    Registered User
    Join Date
    04-19-2019
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Office 365
    Posts
    3

    Re: VBA - extracting from websites

    Hi, thank you so much for the answer. But I can seem to get it to work. Can you might help me? I have the code I use now below:



    Please Login or Register  to view this content.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,385

    Re: VBA - extracting from websites

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. As you are new here, I will do it for you this time.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Registered User
    Join Date
    04-01-2019
    Location
    HK
    MS-Off Ver
    2010
    Posts
    32

    Re: VBA - extracting from websites

    Example:

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    04-19-2019
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Office 365
    Posts
    3

    Re: VBA - extracting from websites

    Attachment 620953

    Thank you so much!
    i'm allmost there. I just have trouble getting this line out. I have triede with this:

    Set objCountryList = objHTML.getElementsByClassName("AspNet-TreeView-ClickableNonLink")(0).getElementsByTagName("span")

    But it just gives me a run-time error '91'

    Am I doing something wrong?

  7. #7
    Registered User
    Join Date
    04-01-2019
    Location
    HK
    MS-Off Ver
    2010
    Posts
    32

    Re: VBA - extracting from websites

    Try:

    Please Login or Register  to view this content.

+ 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. Accessing websites via VBA
    By JonasKl in forum Excel Programming / VBA / Macros
    Replies: 30
    Last Post: 12-13-2016, 10:53 AM
  2. VBA to post to given websites
    By mlmcvinney in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-23-2016, 04:14 PM
  3. Good websites
    By john456852 in forum The Water Cooler
    Replies: 8
    Last Post: 09-02-2013, 10:11 AM
  4. [SOLVED] Automatically Extracting the Domain Names from a list of Websites in Excel 2007
    By retardlike69 in forum Excel Formulas & Functions
    Replies: 23
    Last Post: 10-18-2012, 09:43 AM
  5. [SOLVED] websites
    By Abbo in forum Excel General
    Replies: 1
    Last Post: 08-01-2006, 11:40 AM
  6. websites
    By Abbo in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-01-2006, 10:35 AM
  7. Websites
    By Cottage6 in forum Excel General
    Replies: 7
    Last Post: 12-09-2005, 02:10 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