Solved

Highlighting Cells That Reference External Files

Posted on 2010-11-26
8
297 Views
Last Modified: 2012-05-10
Hi There Experts,

Is there a simple way (including a macro possibly) that I can highlight all the cells in an Excel workbook that have a formula reference to an external file?

Thanks,
rav
0
Comment
Question by:rav_rav
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 12

Expert Comment

by:sstampf
ID: 34218020
You can try this code. Just select the range where you want to test for external links and run the macro. You can also assign a shortcut key to this code.

Thanks
Shashank
Sub sFormat()
Dim rng As Range
For Each rng In Selection
If InStr(2, rng.Formula, "[") Then
rng.Interior.Color = vbBlue
End If
Next rng
End Sub

Open in new window

0
 
LVL 11

Expert Comment

by:Swapnil Nirmal
ID: 34218025
First paste this function by creating module in VBA (press alt+F11, in project viewer right click on the desired file or personal.xls if you want it global
 
Function IsExternalFormula(rCell As Range) As Boolean
If Not rCell.HasFormula Then Exit Function

IsExternalFormula = InStr(1, rCell.Formula, "[") > 0
End Function

Open in new window


in conditional formatting use the following formula:

=IsExternalFormula(A1)
0
 

Author Comment

by:rav_rav
ID: 34218151
Hi Shashank,

Thanks for the quick response.  How would i neeed to modify the code to search the entire workbook?

Thanks,
rav
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Accepted Solution

by:
sstampf earned 500 total points
ID: 34218559
Try this code:
Sub sFormat()
Dim rng As Range, rng1 As Range
Dim sht As Worksheet
For Each sht In ActiveWorkbook.Sheets
Set rng1 = sht.UsedRange
    For Each rng In rng1
        If InStr(2, rng.Formula, "[") Then rng.Interior.Color = vbBlue
    Next rng
Next sht
End Sub

Open in new window

0
 
LVL 13

Expert Comment

by:gbanik
ID: 34218576

Option Explicit

Public Sub HighlightExternalLinks()
Dim oRange As Range, oFindRange As Range, bFindFlag As Boolean
'On Error Resume Next
Do While Err.Number = 0
    If Not bFindFlag Then
        Set oFindRange = ActiveSheet.Cells.Find(What:="[", After:=Cells(1), LookIn:=xlFormulas, LookAt:= _
            xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
            , SearchFormat:=False)
        bFindFlag = True
    Else
        Set oFindRange = ActiveSheet.Cells.FindNext(After:=oFindRange)
    End If
    If Err.Number <> 0 Then
        Err.Clear
        Exit Do
    End If
    If Not oFindRange Is Nothing Then
        If Not oRange Is Nothing Then
            If Not Intersect(oRange, oFindRange) Is Nothing Then Exit Do
        End If
        If oRange Is Nothing Then Set oRange = oFindRange Else Set oRange = Union(oRange, oFindRange)
    Else
        Exit Do
    End If
Loop
If Not oRange Is Nothing Then
    oRange.Interior.ColorIndex = 22
    oRange.Activate
End If
End Sub

Open in new window

0
 

Author Closing Comment

by:rav_rav
ID: 34218678
Great.  Thanks for your help.
0
 
LVL 50

Expert Comment

by:Dave Brett
ID: 34220109
While this question is closed my Mappit! does this amongst other thingss, http://www.experts-exchange.com/A_2613.html

And I note that links should be backtested against Linksources to test they are valid. Finding "[" alone may lead to false link identifictaion


Cheers

Dave
0
 

Author Comment

by:rav_rav
ID: 34231542
Thanks for the info brettdj.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question