+ Reply to Thread
Results 1 to 26 of 26

macro to detect domain names (in url's) ?

  1. #1
    Forum Contributor
    Join Date
    05-10-2011
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    145

    macro to detect domain names (in url's) ?

    Hello friends,
    I have an excel file with a single column, this column has 32 rows, each row has a url in it
    If you look at column A you will see that sometimes the same domain name appear more than a single time (for example: domain1.com/kjh54asfdasd.html, domain1.com/asd.html, and so on...) while some other times the domain name appear only once (for example: domain3.com/kjhgfjasfdasd.html).


    My question:

    Is there a way to make a macro that will do the following 2 things:

    1. Detect all domain names on column A from within the url's (for example: if the url is example.net/aaaaa.asp - then the macro detect example.net as the domain of the url), the detection should support the following domain type: .com, .net, .info, .org, .edu

    2. Extract the first 3 instances of each domain name on column A (together with the entire url) and copy them to column B
    If some domains has less than 3 instances - the macro will copy them as well


    Please see file attached so you see what I mean.
    Attached Files Attached Files
    Last edited by sami770; 01-07-2013 at 06:18 AM.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: macro to detect domain names (in url's) ?

    your sample list does not match your description.
    Ben Van Johnson

  3. #3
    Forum Contributor
    Join Date
    05-10-2011
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    145

    Re: macro to detect domain names (in url's) ?

    The sample file (as could be understood by its name) is just a sample, but the idea is the same.
    However, I just edited the description to fit the sample file.

    My simple question remains the same:
    Is it possible to do the following 2 things with a single macro?

    1. Detect all domain names on column A from within the url's (for example: if the url is example.net/aaaaa.asp - then the macro detect example.net as the domain of the url), the detection should support the following domain type: .com, .net, .info, .org, .edu

    2. Extract the first 3 instances of each domain name on column A (together with the entire url) and copy them to column B
    If some domains has less than 3 instances - the macro will copy them as well


    Again, see the sample file attached on my first post...


    Your help is highly appreciated!



    Quote Originally Posted by protonLeah View Post
    your sample list does not match your description.
    Last edited by sami770; 01-07-2013 at 06:17 AM.

  4. #4
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: macro to detect domain names (in url's) ?

    As requested:

    Please Login or Register  to view this content.
    If you like my contribution click the star icon!

  5. #5
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: macro to detect domain names (in url's) ?

    as an option
    Please Login or Register  to view this content.

  6. #6
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: macro to detect domain names (in url's) ?

    @nilem, as long as the entries are sorted alphabetically that would work too. Your solution does not check on a valid extension though, but I am not sure whether that is really required.

  7. #7
    Forum Contributor
    Join Date
    05-10-2011
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    145

    Re: macro to detect domain names (in url's) ?

    does not work

    Quote Originally Posted by OllieB View Post
    As requested:

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    05-10-2011
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    145

    Re: macro to detect domain names (in url's) ?

    still looking for a solution that support the 5 domain types i specified...
    Last edited by sami770; 01-07-2013 at 02:04 PM.

  9. #9
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: macro to detect domain names (in url's) ?

    Quote Originally Posted by sami770 View Post
    does not work
    Sami, while I have tested it myself without any problems using your own example data and I do appreciate feedback, a bit more information than "does not work" would be appreciated.

  10. #10
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: macro to detect domain names (in url's) ?

    Why don't you provide a copy of the work with the example data and my code so I can check why it does not work?

  11. #11
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: macro to detect domain names (in url's) ?

    Sam,

    I found a typing error. Please change the statement below

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    apologies

  12. #12
    Forum Contributor
    Join Date
    05-10-2011
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    145

    Re: macro to detect domain names (in url's) ?

    Sorry, you are right about
    Please see a sample file that your solution did not work with ;-(

    Quote Originally Posted by OllieB View Post
    Why don't you provide a copy of the work with the example data and my code so I can check why it does not work?
    Attached Files Attached Files

  13. #13
    Forum Contributor
    Join Date
    05-10-2011
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    145

    Re: macro to detect domain names (in url's) ?

    Thanks,
    I replaced the lines according to your instructions but I still get an error from the excel debugger...
    The error message refer to this line in the macro: pvt_str_Extension = Mid$(pvt_str_DomainName, (InStr(1, pvt_str_DomainName, ".")))
    Could you take another look at this please?

    Quote Originally Posted by OllieB View Post
    Sam,

    I found a typing error. Please change the statement below

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    apologies

  14. #14
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: macro to detect domain names (in url's) ?

    Sam,

    the statement attempts to find the extension part of the domain name. If it returns an error then I assume you have domain names without an extension.

    replace the single statement by:

    Please Login or Register  to view this content.

  15. #15
    Forum Contributor
    Join Date
    05-10-2011
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    145

    Re: macro to detect domain names (in url's) ?

    I followed this advice as well...
    Now I did not get debugger error but the final result is not whatI am looking for.
    Instead of filling column B with the first 3 url's of each domain - I got only 3 results total
    If you run your solution with THE SECOND SAMPLE I attached to this thread (http://www.excelforum.com/attachment...8&d=1357583395) you will see what I mean

    Quote Originally Posted by OllieB View Post
    Sam,

    the statement attempts to find the extension part of the domain name. If it returns an error then I assume you have domain names without an extension.

    replace the single statement by:

    Please Login or Register  to view this content.

  16. #16
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: macro to detect domain names (in url's) ?

    Sam,

    Many things were wrong with the code as it did not expect (or check for) http://, https:// prefixes and it also expected the data to start on row 2 as per your previous example. Please check the enclosed workbook
    Attached Files Attached Files

  17. #17
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: macro to detect domain names (in url's) ?

    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  18. #18
    Forum Contributor
    Join Date
    05-10-2011
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    145

    Re: macro to detect domain names (in url's) ?

    Yes, I really needed a quick answer so I posted my question also there, I hope its Ok.

    Quote Originally Posted by jaslake View Post

  19. #19
    Forum Contributor
    Join Date
    05-10-2011
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    145

    Re: macro to detect domain names (in url's) ?

    Finally you did it right
    PERFECT, SIMPLY PERFECT
    Thank you so much for your time and efforts, I do appreciate it!
    Quote Originally Posted by OllieB View Post
    Sam,

    Many things were wrong with the code as it did not expect (or check for) http://, https:// prefixes and it also expected the data to start on row 2 as per your previous example. Please check the enclosed workbook

  20. #20
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: macro to detect domain names (in url's) ?

    No, not OK...read the Forum Rules on the proper etiquette. You MAY do so if you follow the proper etiquette. The other Forum has the same rule.

  21. #21
    Forum Contributor
    Join Date
    05-10-2011
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    145

    Re: macro to detect domain names (in url's) ?

    OK,
    I got you & agree
    It will NOT happened again!
    Sami

    Quote Originally Posted by jaslake View Post
    No, not OK...read the Forum Rules on the proper etiquette. You MAY do so if you follow the proper etiquette. The other Forum has the same rule.

  22. #22
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: macro to detect domain names (in url's) ?

    OK Sami...go in Peace...glad you got resolution.

  23. #23
    Forum Contributor
    Join Date
    05-10-2011
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    145

    Re: macro to detect domain names (in url's) ?

    Thank you!
    And...yes, finally I got the perfect solution
    I do appreciate OllieB's help a lot!

    Quote Originally Posted by jaslake View Post
    OK Sami...go in Peace...glad you got resolution.

  24. #24
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: macro to detect domain names (in url's) ?

    Your post does not comply with Rule 12 of our Forum RULES. Don't quote whole posts -- it's just clutter. If you are responding to a post out of sequence, limit quoted content to a few relevant lines that makes clear to whom and what you are responding.

  25. #25
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: macro to detect domain names (in url's) ?

    @protonLeah

    Give the kid a break...I just hammered her!

  26. #26
    Forum Expert OllieB's Avatar
    Join Date
    12-20-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2007 (home) & 2010 (office)
    Posts
    1,542

    Re: macro to detect domain names (in url's) ?

    Quote Originally Posted by sami770 View Post
    PERFECT, SIMPLY PERFECT
    Thank you so much for your time and efforts, I do appreciate it!
    You are very welcome. Please mark your thread as SOLVED when you have a moment.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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