I kept getting the Edit Links message when I opened this on particular file, but I could never find the link. It wasn’t in any formulas or range names. I ended up copying each cell to a new worksheet and seeing when that new worksheet got the link. Fortunately it was about the 10th cell that I copied. I figured out that the data validation list referred to a named range. I’m pretty sure that the named range still exists in whichever workbook this sheet was copied from. I’d rather not discuss how long it took me to find the source of this problem, so I’ll just post the code I used to find all its cousins.
Sub FindLinksInValidation()
Dim rCell As Range
Dim sDvForm As String
For Each rCell In ActiveSheet.UsedRange.Cells
‘Store the Formula1 property if there is one
On Error Resume Next
sDvForm = “”
sDvForm = rCell.Validation.Formula1
On Error GoTo 0
‘If Formula1 has a bracket, it’s a good candidate
‘for containing an external link
If InStr(1, sDvForm, “]”) > 0 Then
Debug.Print rCell.Address, rCell.Validation.Formula1
End If
Next rCell
End Sub
Dim rCell As Range
Dim sDvForm As String
For Each rCell In ActiveSheet.UsedRange.Cells
‘Store the Formula1 property if there is one
On Error Resume Next
sDvForm = “”
sDvForm = rCell.Validation.Formula1
On Error GoTo 0
‘If Formula1 has a bracket, it’s a good candidate
‘for containing an external link
If InStr(1, sDvForm, “]”) > 0 Then
Debug.Print rCell.Address, rCell.Validation.Formula1
End If
Next rCell
End Sub
Of course Bill Manville’s Findlink would have speeded up the find process quite a bit:
http://www.oaltd.co.uk/mvp
Why not Edit – Find – Find: “]” – Find all ?
FindLink did not work for me. The code was password protected so I couldn’t see if it looked in data validation or not. That was the second thing I tried.
Edit – Find did not work for me – it was the first thing I tried. Is it supposed to work in data validation? It didn’t or I was doing something wrong.
Flexfind would have located them without a problem, make sure you check “Objects” and look in formulas.
It takes some work to use external references in data validation, so it may be karma that it takes some work to find such external references. Or maybe it a paraphrase of one of life’s rules: no bit of cleverness goes unpunished.
Flexfind worked great for a non-programmer. thanks. Tried to make a contribution to the developer through their site and their Paypal account but was told there was an error. Sorry
Actually fzz, it is VERY easy to create an external link for data validation… copy the cells with the data validation into another workbork and voila… you have a file that uses an external file for data validation… a real pain to find and resolve these.
This macro did not work for me by the way…. no results but I still get an error message when I open the file.
Follow-up… I found my links… there were embedded in conditional formatting rules…
So now I’ve added this to my checklist:
1. Search Formulas with Find for links to external files
2. Search Range Names for ranges in external files.
3. Search Data Validation rules for every cell to see if any of them are sourced from a list in an external file.
4. Search Conditional Formatting rules to see if any of them are conidtional and cells in external files.
If only there was a single place in Excel to find, edit, and break external links….
OK, this is a thread since long time back, but it really helped me out. never thought of looking into conditional formatting! Great!
Buttons and combo boxes can also contain references to macros and control cells in other worksheets.
This is an old thread, but also a topic that has caused me a lot of pain, so I hope this helps someone. I modified Dick Kusleika’s code above slightly. This variation will unhide every worksheet in your file, create a new worksheet called ‘external links’, and then list all the worksheets and cells where it finds a link within the data validation in the ‘external links’ worksheet. It’s a bit slow, but faster than digging through the file manually.
End Sub
On the hunt again and found this thread again, nice add Peter. Thanks!
On the hunt again and found this thread again, nice add Peter but one typo came through, your > shows as > ;
should be
Thanks!
Thanks for the comment Howard. I don’t know why this site can’t render HTML appropriately, but I’m working on a fix.
To everyone that has contributed on this thread and in particular to Dick for creating the post and Peter for enhancing the script, THANK YOU. I’ve had a workbook that has been troubling me with this issue for way too long and now it’s resolved!
How can Peter Malczyk’s code be amended to also find links within conditional formatting?
Hi all
As usually, a very helpful piece of code. It just saved my day – actually two of them, when I was struggling to remove the external links error message.
I did a minor amendment to get the formula put in as well:
1) Adding:
Sheets(“External links”).Cells(1, 3).Value = “Formula”
2) Replacing the uncommented output line by
Sheets(“external links”).Cells(counter, 3).Value = “””” & rCell.Validation.Formula1 & “”””
This will put the formula as text string into it instead of evaluating it – giving an error. The double quote formatting is for the European theatre.
thank you Peter Malczyk
Hi,
Thanks a lot for the code, very helpful.
I did some very minor improvement.
1/ I don’t think it is necessary to unhide the worksheet (tested on XL 2016, even with xlVeryHidden)
2/ I store the result in an array before sending to the worksheet ( a bit faster for lost of cells).
3/ I used activeworkbook instead of thisworkbook
Comments are very welcome.
Thank you.
Gaetan
I’d prefer