checking in vba if item is found within a range

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

Guest

I have used the following code in the past but it no longer works in the
newer versions of Excel. Is there another way to check if an item is found or
not within a range.

Evern though it shows c equal to Nothing in watch mode, the code used below
gives an error.

Sub testFindDate()
With Range("K4:K45")
Set c = .Find("7/1/2006")
End With
If c.Value = "Nothing" Then
MsgBox "not found"
Else
MsgBox c.Address
End If
 
Sub testFindDate()
Dim c As Excel.Range
Set c = Range("K4:K45").Find("7/1/2006")
If c Is Nothing Then
MsgBox "not found"
Else
MsgBox c.Address
End If
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"djb"
<[email protected]>
wrote in message
I have used the following code in the past but it no longer works in the
newer versions of Excel. Is there another way to check if an item is found or
not within a range.
Evern though it shows c equal to Nothing in watch mode, the code used below
gives an error.

Sub testFindDate()
With Range("K4:K45")
Set c = .Find("7/1/2006")
End With
If c.Value = "Nothing" Then
MsgBox "not found"
Else
MsgBox c.Address
End If
 

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