Consulting

Results 1 to 4 of 4

Thread: Get absolute address for hyperlinks

  1. #1

    Get absolute address for hyperlinks

    I'm using Excel 2003.
    Have a macro that extracts all the hyperlinks and does a text search and replace. For those hyperlinks that do not contain the search string I write to a "StringNotFound" spreadsheet. However, if a spreadsheet contains hundreds or thousands of links that it would be tedious to locate exactly what cell the hyperlink is located in. So, what I would like to do is obtain the absolute cell location and provide that info in the "StringNotFound" along with contents of the hyperlink. How can I get the cell reference information in the form of A1, C24, etc for each cell that contains a hyperlink.

    Dim h as Hyperlink
    dim hypstr as String
    For each h in Worksheets("XYZ").Hyperlinks
    hypstr = h.address      'how do I get the cell location of h????
         If replacestring does not exit in hypstr then write to StringNotFound
    next
    Last edited by Aussiebear; 04-22-2023 at 12:19 AM. Reason: Adjusted the code tags

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Welcome to the forum!

    Please put code between VBA tag codes. Press the VBA icon and paste between codes.

    hypstr = h.Range.Address
    Last edited by Aussiebear; 04-22-2023 at 12:19 AM. Reason: Adjusted the code tags

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Thanks for that one Ken, I've put it to good use already!
    Regards
    Malcolm
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    Thank you...I was very close with my attempts, but didn't get it exactly. Thank you again, that saved me alot of time and frustration.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •