Using cell value in VBA sub

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
 
H

Harald Staff

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top