Using cell value in VBA sub

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm using the following sub

Sub FindRow()
Dim rngFound As Range


Set rngFound = Range("A:A").Cells.Find(What:="test", _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
MatchCase:=False)
If rngFound Is Nothing Then
MsgBox "Sorry ""test"" was not found"
Else
rngFound.EntireRow.Select
End If
End Sub

My problem is that if I excange Test with a1 - wanting to look the value in
cell a1 I always get the first blank a-cell. I have removed the "". What is
wrong?

Lupus
 
Hi again

Set rngFound = Range("A2:A65536").Cells.Find(What:=Range("A1").value, _

But it may find itself; A1 is in the search area...

HTH. Best wishes Harald
 
Sub FindRow()
Dim rngFound As Range


Set rngFound = Range("A:A").Cells.Find(What:=Range("a1"), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
MatchCase:=False)
If rngFound Is Nothing Then
MsgBox "Sorry ""test"" was not found"
Else
rngFound.EntireRow.Select
End If
End Sub
 
Back
Top