+ Reply to Thread
Results 1 to 28 of 28

Check existense of URL's

  1. #1
    Registered User
    Join Date
    07-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    22

    Check existense of URL's

    I have a document with ~70,000 URL's in column A.
    I want to check for each cell if the URL actually works (so the website can be opened and does not return an error).
    If it does not work, I want cell B in the same row to be filled with a "*".

    Is this possible and if so could someone provide me with a code sample?

  2. #2
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Check existense of URL's

    How do you know that the page does not exists anymore? What do you see in the browser?

    Can you provide and example?

    Thanks

  3. #3
    Registered User
    Join Date
    07-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: Check existense of URL's

    So that would be something to be checked by programatically opening that URL. Normally I develop in .NET and I can open a httprequest and check the response. So for each of these URL's I would like to check what the response is. But I need it to be done in Excel. Does that clarify what I need?

  4. #4
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Check existense of URL's

    Hi,

    I was looking for what was being check in the response. Yeah that's the way I would go. Here is some code to help you.

    So if the keyword is in the response of if there is any other error cause by a HTTPrequest failure then the function will return a bad url.

    Please Login or Register  to view this content.
    Hope this helps

  5. #5
    Registered User
    Join Date
    07-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: Check existense of URL's

    Thanks, I'm pretty new to all this and using Excel 2013. Where would I add this code and how would I run it? I added a new module to my VBA project but then have no idea what's next...

  6. #6
    Registered User
    Join Date
    07-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: Check existense of URL's

    @fredlo2010: any (further) help you can provide me here? Thanks ahead!

  7. #7
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Check existense of URL's

    Hey Peter;

    Give this page a read and you will be all set.

    https://www.ablebits.com/office-addi...a-macro-excel/

    Thanks

  8. #8
    Registered User
    Join Date
    07-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: Check existense of URL's

    Hi Fred. Thanks!
    I followed the steps on the link you provided.

    I then ran the Marco 'MainRunner' on column L (not sure what macros "TurnExtrasOn" and "TurnExtrasOff" do)
    I know that some links that are in column L definitely exist and some definitely don't.

    What happens is that after completion of the macro a "*" is added in ALL rows in column B.

    Also, I'm not sure if your macro requires the links to be checked to be true Excel hyperlinks (so blue underlined)

    Am I doing something wrong?

  9. #9
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Check existense of URL's

    I am not sure,

    Can you post a sample of your workbook ?

    The links have to be just links like the address you would type in the browser.

    Thanks

  10. #10
    Registered User
    Join Date
    07-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: Check existense of URL's


  11. #11
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Check existense of URL's

    Hi,

    The code just ran fine for me.


    just change this section because your links are in column "K"

    Please Login or Register  to view this content.

    and the only invalid website was

    "http://www.denisanddennis.com"


    Thanks

  12. #12
    Registered User
    Join Date
    07-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: Check existense of URL's

    Ah, it works indeed! However, my original files has way more links and performance becomes an issue I now notice. Is there a way to run the macro only on cells I manually select?

  13. #13
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Check existense of URL's

    Try this

    Please Login or Register  to view this content.
    Thanks

  14. #14
    Registered User
    Join Date
    07-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: Check existense of URL's

    Thanks! I updated the sheet on www.lalisto.nl/files/sample.xlsm with your code. I get the dialog asking me if I selected individual ranges.
    However, it again adds a * for all sites again in column L.
    What am I doing wrong this time?

  15. #15
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Check existense of URL's

    You need to modify this line

    Please Login or Register  to view this content.
    thanks

  16. #16
    Registered User
    Join Date
    07-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: Check existense of URL's

    This looks as if i need to know what value will be returned by the request...I was more hoping the code would pick up on the httpresponse code, e.g. only 200 is considered to be a correct url.
    I'm not sure what this constant value is exactly doing?

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

    Re: Check existense of URL's

    So why don't you just check the response code?

  18. #18
    Registered User
    Join Date
    07-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: Check existense of URL's

    Yeah, I tried that by doing this:
    Please Login or Register  to view this content.
    But that also just generates a "*" in each row....even though I know some urls exist.
    Last edited by peterkerk; 02-20-2015 at 11:27 AM.

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

    Re: Check existense of URL's

    Have you got an example of one which you think is valid, but doesn't return a 200?

  20. #20
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Check existense of URL's

    Peter please use code tags in your post. Thanks

    And yeah we will need and example.

  21. #21
    Registered User
    Join Date
    07-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: Check existense of URL's

    @Fred: Thanks, I updated that post.
    Also updated the sample.xlsm:
    All sites should return a 200 except www.denisanddennis.com
    Also see in the sample that for all URL's the column next to it is marked with a "*"

  22. #22
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Check existense of URL's

    Hello,

    It was my bad. I had a bad code in the IsGoodURL function.

    The line bellow is invalid
    Please Login or Register  to view this content.

    This is the new fully tested function. I have also changed the code to check status.
    Please Login or Register  to view this content.
    This is a sample of the working file
    sample.xlsm

    Thanks
    Last edited by fredlo2010; 02-20-2015 at 11:37 AM.

  23. #23
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Check existense of URL's

    Please look at my previous post

  24. #24
    Registered User
    Join Date
    07-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: Check existense of URL's

    That works! Thanks!
    One final question: I'm selecting and checking around 500 URL's per batch, but then I get "Excel is not responding"...Now I also already got this when checking just 5 URLs, but apparently it still is working correctly. Is there some way to show if this macro is really doing something (maybe a progress bar or something) or that Excel is actually stuck and not doing anything?

  25. #25
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Check existense of URL's

    You can do that with for example the code bellow will write to the Statusbar the word "Number"

    Please Login or Register  to view this content.
    As per excel been unresponsive that's how it is maybe if you use oHTTP.send asynchronously? then you will have to check if it finished or something with a loop.

    If this is a one time operation why don't you just start it and go to lunch and when you come back the code should have finished No batch the whole thing.

    Thanks

  26. #26
    Registered User
    Join Date
    07-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: Check existense of URL's

    Ok, thanks for all this!

  27. #27
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: Check existense of URL's

    I am glad I was able to help.

  28. #28
    Registered User
    Join Date
    07-10-2012
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    22

    Re: Check existense of URL's

    @Fred: Sorry, I'm running into one more thing!

    I found that this URL
    http://gatheringsde.com
    redirects to
    http://gatheringsdelaware.com/

    Both the check for responsecode 200:
    Please Login or Register  to view this content.
    as well as this check:

    Please Login or Register  to view this content.
    Fail to recognize that link http://gatheringsde.com actually points to a correct URL.

    I also setup a test with an actual 301 redirect www.trouwlocaties.com/test.php, but my code fails to recognize that.

    How can I check for 301/302 responses?

+ 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. possible to check for file in multiple folders, then check for values in specific cells?
    By mattheritage in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-04-2014, 08:33 AM
  2. Automatically check one or more check boxes when a parent check box is manually checked
    By Steverizer in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-28-2013, 01:56 PM
  3. Replies: 1
    Last Post: 12-14-2012, 10:11 AM
  4. Macro to force format and check barcode check digit
    By Code Flunkie in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-02-2009, 10:27 AM
  5. Macro to check for blank cell entry, copy previous value, and check for duplicates
    By xPunxNotDeadx in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-26-2009, 06:33 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