Question : Excel VBA Find Linked Cells

Hi,

I am trying to write a script that will loop through all the worksheets in my workbook and search for linked cells to a particular address  "frrr/isis"

Any help would be great

Thanks

Mark

Answer : Excel VBA Find Linked Cells

Aaron Blood wrote an excellent general purpose find routine ("Kickbutt Find") at http://www.xl-logic.com/modules.php?name=Downloads&d_op=getit&lid=228   You may have to register for this site to get to that link.

I added a macro to call that find routine to search all sheets for text that you specify in formulas. It will then select all such cells. As you go from worksheet to worksheet, you can then review those selections.

If you were looking for formulas that reference a named range like frrr_isis, just enter that text in response to the input box.

Brad
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
Sub SearchAllSheets()
Dim ws As Worksheet
Dim rg As Range
Dim FindText As String
FindText = Application.InputBox("Please enter the address or named range you want to find")
For Each ws In ActiveWorkbook.Worksheets
    Set rg = Nothing
    Set rg = Find_Range(FindText, ws.Cells, xlFormulas, xlPart, False)
    If Not rg Is Nothing Then
        ws.Activate
        rg.Select
    End If
Next
End Sub

'Find_Range written by Aaron Blood
Function Find_Range(Find_Item As Variant, _
    Search_Range As Range, _
    Optional LookIn As XlFindLookIn = xlValues, _
    Optional LookAt As XlLookAt = xlPart, _
    Optional MatchCase As Boolean = False) As Range
     
    Dim c As Range, FirstAddress As String
     
    With Search_Range
        Set c = .Find( _
            What:=Find_Item, _
            LookIn:=LookIn, _
            LookAt:=LookAt, _
            SearchOrder:=xlByRows, _
            SearchDirection:=xlNext, _
            MatchCase:=MatchCase, _
            SearchFormat:=False) 'Delete this term for XL2000 and earlier
        If Not c Is Nothing Then
            Set Find_Range = c
            FirstAddress = c.Address
            Do
                Set Find_Range = Union(Find_Range, c)
                Set c = .FindNext(c)
            Loop While Not c Is Nothing And c.Address <> FirstAddress
        End If
    End With
     
End Function
Random Solutions  
 
programming4us programming4us