Well... like this, I guess?
Option Explicit
Sub Test()
Dim rngResult(0 To 1) As Excel.Range
Dim rngCell As Excel.Range
Dim strWhat As String
'e.g. Range("A1")
' -> search row 1 for strWhat
' -> search column A for strWhat
' => on success: both results get combined to rngCell
With Worksheets("Sheet1").Range("A1")
strWhat = "Match"
Set rngResult(0) = .EntireRow.Find( _
What:=strWhat, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
MatchCase:=False)
Set rngResult(1) = .EntireColumn.Find( _
What:=strWhat, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByColumns, _
MatchCase:=False)
If Not (rngResult(0) Is Nothing Or rngResult(1) Is Nothing) Then
Set rngCell = .Worksheet.Cells(rngResult(1).Row, rngResult(0).Column)
End If
If rngCell Is Nothing Then
Call MsgBox("No entry was found for value '" & strWhat & "'.", vbExclamation)
Else
Call MsgBox("Cell for value '" & strWhat & "'" & vbNewLine & _
" -> " & rngCell.Address() & " = '" & rngCell.Value & "'", _
vbInformation)
End If
End With
End Sub
|