Hi,

I'm trying to write a function for worksheet use that will search through every single in cell in all open books and return the name of the book that matches the supplied value. However, the problem is that the function will always attempt to search the cell that it's called from, resulting in a circular reference. Is there a way to make the search skip over the cell that it was called from? Or alternatively, can I just have it skip over the workbook that the function is in?

Function AppearsInBook(SearchVal As Variant) As String

Dim RowNo As Long
Dim ColNo As Long

Dim Sht As Worksheet
Dim OpenBk As Workbook
Dim Cell As Range

For Each OpenBk In Workbooks
    'If this is the cell that the function was called from, skip it...
    Debug.Print OpenBk.Name
    
    For Each Sht In OpenBk.Worksheets
        Debug.Print Sht.Name
        
        For Each Cell In Sht.UsedRange.Cells
            '...or, if this is the cell that the function was called from, skip it.
            Debug.Print "*" & Cell.Value & "*"
            
            If Cell.Value = SearchVal Then
                AppearsInBook = OpenBk.Name
                Exit Function
            End If
            
        Next Cell
        
    Next Sht
    
Next OpenBk

End Function
Many thanks!