+ Reply to Thread
Results 1 to 13 of 13

List of Internal links

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    List of Internal links

    I've inherited a workbook that at present count has 57 tabs, each of which has hundreds of links to other worksheets in the workbook. I'm trying to make sense of it all and bring some order to it, but it's a mess. What would help me out is to get a list of all the formulas that reference other sheets. Ideally I'd want a single sheet with 3 columns, the first showing the formula, the second showing what sheet the formula's in, and the 3rd showing what cell in that sheet the formula comes from.

    I've looked and can't find much for hunting down internal links. The below macro is one I copied a long time ago and never fooled with. It's got a start, but I'm lost on how to expand it to bring in all the values I need and consolidate it into a single worksheet. Any help would be highly appreciated.
    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: List of Internal links

    Well, I thought about it, and found a solution. I turned a macro for finding all formulas in a workbook into one that whittles it down to JUST the internal links. Code is below:
    Please Login or Register  to view this content.

  3. #3
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: List of Internal links

    Hi there,

    Is this routine a little bit shorter?

    The code assumes that a "Formulas" worksheet already exists in the workbook.

    Please Login or Register  to view this content.
    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Last edited by Greg M; 10-02-2015 at 05:50 PM. Reason: Minor addition

  4. #4
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: List of Internal links

    Shorter, but upon running I get a run-time error of 1004 saying "no cells were found" on the line:
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: List of Internal links

    Greg,
    I altered your code just a little bit, and it appears to work flawlessly, and blazingly fast. Good job! Here's the changes I did:
    1) Turned off Calculation and Screen Updating at the front, turned it back on at the end
    2) Put in a Check to see if ws "Formulas" already exists. If so, deletes the "Formulas" used range for a fresh start. If not, creates the sheet.
    3) Put my column headings in the "Formulas" sheet
    4) Put in a check in case it hits a page with no formulas.
    5) Changed "ThisWorkbook" to "ActiveWorkbook" so I can add the code to my personal and use it wherever I need to.

    Updated code is below. Thanks so much of this, it's much faster than my previous code.
    Please Login or Register  to view this content.
    Last edited by jomili; 10-05-2015 at 09:31 AM.

  6. #6
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: List of Internal links

    Hi again,

    Many thanks for this very useful feedback - it's always interesting to see the "tweaks" that are applied afterwards.

    You're very welcome - glad I was able to help.

    Best regards,

    Greg M

  7. #7
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: List of Internal links

    Hi again,

    I've had a closer look at your code and can suggest just a small improvement.

    There's quite a bit of code nested between the following "On Error resume Next - On Error GoTo 0" statements:

    Please Login or Register  to view this content.

    In general, you should always try to reduce the amount of such code to an absolute minimum. The following version helps to do this:

    Please Login or Register  to view this content.

    Just for information, I've also included alternative code for creating/clearing the Formulas worksheet.

    Hope this might be of some use or interest to you, and thanks again for your feedback.

    Regards,

    Greg M

  8. #8
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: List of Internal links

    Please Login or Register  to view this content.



  9. #9
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: List of Internal links

    snb,
    I really enjoy how you can take something complex and whittle it down to only a very few names. I gave your macro a whirl, and ran into a couple of snags. I think the following code is to check if sheet "inventory" exists, and if not to add it, or if it does exist write the information to it.

    [CODE][/If [iserr(isref(inventory!A1))]CODE]
    If no sheet "inventory" exists, the macro does nothing. Walking through it, it skips over the "Sheets.Add.name = "inventory"" line and goes to the "Resize" line, but since no inventory sheet exists nothing happens.

    IF an "inventory" sheet DOES exist, the code works fine, except that it places the formula, not the formula with an apostrophe in front of it.

    I don't understand the "If [iserr(isref(inventory!A1))]" enough to be able to figure out the problem, so I hope you can explain.

    Thanks,
    John

  10. #10
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: List of Internal links

    Greg,
    Thanks for your suggested improvements. I never thought about reducing the clutter between error checking statements, but that makes sense to me. I like the "ClearContents" rather than "Delete"; that way if I have any fancy formatting set up I shouldn't lose it.

    Thanks for all your help!

  11. #11
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: List of Internal links

    SNB,
    I resolved my issues with your code.
    Please Login or Register  to view this content.
    Now the only thing I want to add is headers to my columns.

    Edit: Apparently I didn't fix it. If an "inventory" sheet exists, these two statements both trigger the msgbox:
    Please Login or Register  to view this content.
    Trying with the original statements, if "inventory" sheet exists, it works fine, if it doesn't exist, no sheet is added.
    Last edited by jomili; 10-06-2015 at 12:43 PM. Reason: Found a flaw

  12. #12
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: List of Internal links

    Okay, I think I've got it this time. Seems the problem was "iserr". I replaced with "not", and it appears to be working fine. I also tweaked it to add my headings and autofit my columns.
    Please Login or Register  to view this content.

  13. #13
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: List of Internal links

    Hi again,

    Many thanks for this feedback - it's always good to have!

    You're very welcome - glad you found my last post useful.

    Best regards,

    Greg M


    P. S. Many thanks for your kind words and for the Reputation increase - much appreciated.
    Last edited by Greg M; 10-07-2015 at 04:55 AM. Reason: P. S. added

+ 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. Break internal and external links of selected tabs.
    By lalaarif1 in forum Excel General
    Replies: 1
    Last Post: 05-17-2015, 05:47 AM
  2. Tab links in a drop down list via VB
    By michaelof36 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-03-2014, 09:58 PM
  3. Replies: 0
    Last Post: 01-04-2014, 09:26 AM
  4. [SOLVED] Find and List Links
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-26-2012, 12:08 PM
  5. [SOLVED] Convert external links to internal
    By Marie J-son in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-26-2006, 11:55 PM
  6. Internal links
    By Job in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-26-2005, 03:05 PM
  7. EXCEL - LINKS cannot easily get list of all links & names in book
    By Tuba Joe in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-29-2005, 06:05 PM

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