Solved

Highlighting Cells That Reference External Files

Posted on 2010-11-26
8
283 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
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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

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;…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

778 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