View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Incidental Incidental is offline
external usenet poster
 
Posts: 226
Default Conditional Find

Hi Steve

You could try something like the code below that should give you an
idea of how to do what your after. I added this code to a user button
but it could be amended to fit what ever you like.

Option Explicit
Dim MyDate As Date 'declare your variable as a date

Private Sub CommandButton1_Click()

MyDate = InputBox("Please Enter a Date", "Date Finder") 'enter a date
to find

On Error Resume Next 'add this to trap the error on date not found

With Range("TestRng") 'set the range to search

.Find(What:=MyDate, LookAt:=xlWhole).Activate 'if found activate
the cell

If ActiveCell.Value = MyDate Then ' if active cell matches
your date do this

MsgBox "Run the code for a finding a date"

Else 'if it doesn't match then do this

MsgBox "Run the code for a date not found"

End If

End With

End Sub

Hope this helps

S