Define a Range in Excel by selecting a series of records and entering a name in the NameBox
Public Function IsInRange(RangeName As String, FindString As String) Dim Rng As Range With Sheets("Ranges").Range(RangeName) Set Rng = .Find(What:=FindString, _ After:=.Cells(1), _ LookIn:=xlValues, _ LookAt:=xlWhole, _ SearchOrder:=xlByRows, _ SearchDirection:=xlPrevious, _ MatchCase:=False) If Not Rng Is Nothing Then 'Application.Goto Rng, True IsInRange = True Else 'MsgBox "Nothing found" IsInRange = False End If End With End Function
Usage
If IsInRange("RangeSalesReturns", "FLR5") Then Msgbox("Found in range") Else MsgBox("Not found in range", False) End If