find command using variables

  • Thread starter Thread starter eyecalibrate
  • Start date Start date
E

eyecalibrate

Help. I'm having trouble using an established variable in a find.
want to find a certain value in...say column A. Probably a synta
error on my part. I can't seem to find a way to use "MyVar1" as
value in a find. Any suggestions
 
Hi Eyecalibrate,

Sub Tester()
Dim rng As Range
Dim myVar1 As String

myVar1 = "ABC"

With ActiveSheet.Columns("A:A")
Set rng = .Find(myVar1, LookIn:=xlValues)
If Not rng Is Nothing Then
MsgBox rng.Address
Else
MsgBox myVar1 & " not found in specified range"
End If
End With

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

Back
Top