If You want to find any string in whole sheet then Give a try to Below Code:
Code:
Sub SelectXCells(strSearch As String)
Dim rngWhole As Range
Dim rngUni As Range
Dim lngRow As Long
Dim lngCol As Long
Dim rngCell As Range
Set rngWhole = ActiveSheet.UsedRange
For Each rngCell In rngWhole
If InStr(1, rngCell, strSearch, vbTextCompare) > 0 Then
If rngUni Is Nothing Then
Set rngUni = rngCell
Else
Set rngUni = Union(rngUni, rngCell)
End If
End If
Next rngCell
On Error Resume Next
rngUni.Select
On Error GoTo 0
End Sub
Example:
Code:
Sub Test()
Dim strFind As String
strFind = InputBox("Please enter string to find", "Find String in Used Range")
SelectXCells (strFind)
End Sub
Bookmarks