+ Reply to Thread
Results 1 to 12 of 12

Count number of occurrences of text in URL

  1. #1
    Registered User
    Join Date
    02-26-2014
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    46

    Count number of occurrences of text in URL

    Hi guys,

    Is it possible to look into a URL (that is placed in column A1 for example) and input the number of times a given piece of text appears in its' HTML (in column B1 for example)?

    Any suggestions/advice/help will be very much appreciated .

    Thanks

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,082

    Re: Count number of occurrences of text in URL

    Try
    =(LEN(A1)-LEN(SUBSTITUTE(A1,B1,""))/LEN(B1)
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,964

    Re: Count number of occurrences of text in URL

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  4. #4
    Registered User
    Join Date
    02-26-2014
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: Count number of occurrences of text in URL

    Hi,

    Thanks for the help Sintek and Special-K but I think I may not have explained my problem properly. I don't want to look for something in the actual URL text. I need Excel to look into the contents of the URL and count how many times a particular piece of text is mentioned within the contents of that page - not within the URL string. I hope that makes sense.

    Thanks

  5. #5
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,964

    Re: Count number of occurrences of text in URL

    Hi james19

    Check out this link...Not sure if it can assist
    http://stackoverflow.com/questions/1...l-in-excel-vba

  6. #6
    Registered User
    Join Date
    02-26-2014
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    46
    Quote Originally Posted by sintek View Post
    Hi james19

    Check out this link...Not sure if it can assist
    http://stackoverflow.com/questions/1...l-in-excel-vba
    Thanks for sending this link. Ive had a brief look and will look into it in more detail tomorrow. I also foubd this which may do what I need: https://www.import.io/post/how-to-get-live-web-data-into-a-spreadsheet-without-ever-leaving-excel/

  7. #7
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Count number of occurrences of text in URL

    Something like below? Note that it looks in .responseText in it's entirety and not what's displayed on web site as text.
    Code also requires Windows machine.
    Please Login or Register  to view this content.
    See attached sample.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    02-26-2014
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: Count number of occurrences of text in URL

    Hi CK76,

    Thanks for the code but unfortunately it returns a runtime 429 error and says activeX object can't create object. The error is on the 'With CreateObject("MSXML2.serverXMLHTTP")' part of the code. I'm guessing this is because I'm using a Mac and as you said, this needs a Windows machine to run. Is there a way to change this code so it works on a Mac?

    Thanks

  9. #9
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Count number of occurrences of text in URL

    To my knowledge, there isn't XMLHTTP/WinHttp equivalent in MAC.

    You can try using WebQuery/QueryTables like mentioned in link.
    http://stackoverflow.com/questions/1...excel-2011-vba
    https://support.microsoft.com/en-us/...-excel-for-mac

  10. #10
    Registered User
    Join Date
    02-26-2014
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: Count number of occurrences of text in URL

    Quote Originally Posted by CK76 View Post
    To my knowledge, there isn't XMLHTTP/WinHttp equivalent in MAC.

    You can try using WebQuery/QueryTables like mentioned in link.
    http://stackoverflow.com/questions/1...excel-2011-vba
    https://support.microsoft.com/en-us/...-excel-for-mac
    Cool thanks. I'll take a look at the links you sent and try to get your code working on Mac.

  11. #11
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: Count number of occurrences of text in URL

    Here's one that might work better, using shell/MacScript.
    http://stackoverflow.com/questions/1...a-for-mac-2011

  12. #12
    Registered User
    Join Date
    02-26-2014
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: Count number of occurrences of text in URL

    Quote Originally Posted by CK76 View Post
    Here's one that might work better, using shell/MacScript.
    http://stackoverflow.com/questions/1...a-for-mac-2011
    Thanks CK76. It's starting to go above my level now but I'll have a look anyway.

+ 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. Count number of occurrences and return in text
    By Meggo12 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-04-2016, 09:14 AM
  2. [SOLVED] Need to count occurrences of a text + increasing number on the same cell
    By Valco in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-16-2015, 12:19 PM
  3. [SOLVED] Count number of occurrences but if there are consecutive matches count them as one
    By michaljireht in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-26-2013, 08:26 PM
  4. [SOLVED] Count number of occurrences for a number of ranges from a find loop
    By ANDREWA in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-23-2012, 07:53 PM
  5. Formula to Count the Number of Occurrences of a Text String in a Range
    By poug1903 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-10-2011, 06:49 AM
  6. Replies: 1
    Last Post: 09-18-2009, 04:15 PM
  7. Count number of occurrences
    By MarkM in forum Excel General
    Replies: 1
    Last Post: 07-27-2006, 05:15 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