ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   find command using variables (https://www.excelbanter.com/excel-programming/311258-find-command-using-variables.html)

eyecalibrate[_6_]

find command using variables
 

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

--
eyecalibrat
-----------------------------------------------------------------------
eyecalibrate's Profile: http://www.excelforum.com/member.php...nfo&userid=662
View this thread: http://www.excelforum.com/showthread.php?threadid=26303


Norman Jones

find command using variables
 
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

---
Regards,
Norman



"eyecalibrate" wrote in message
...

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


--
eyecalibrate
------------------------------------------------------------------------
eyecalibrate's Profile:
http://www.excelforum.com/member.php...fo&userid=6621
View this thread: http://www.excelforum.com/showthread...hreadid=263032





All times are GMT +1. The time now is 01:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com