Finding a date through an Input Box

SarahB

New Member
Joined
Oct 10, 2002
Messages
2
I want to be able to find a date in a set range as specified through an input box. Dates for some reason seem to cause me a problem - any ideas?
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hi SarahB,

See if you can modify the following to suit your requirements:

<pre>Sub findit()
Dim FindMe As Date, c As Range, TestArea As Range
Dim firstaddress As String

GetDate:
FindMe = InputBox("Please enter the search date below." & _
vbLf & vbLf & "Use this format DD/MM/YY.", "Date Entry")
If Not IsDate(FindMe) Then
MsgBox "You didn't enter a date!"
GoTo GetDate
End If

Set TestArea = ThisWorkbook.Sheets("Sheet1").Range("A1:A20")

With TestArea
Set c = .Find(What:=FindMe, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
If Not c Is Nothing Then
firstaddress = c.Address
Do
c.Interior.ColorIndex = 4
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstaddress
End If
End With

Set TestArea = Nothing
Set c = Nothing

End Sub</pre>

HTH
 
Upvote 0

Forum statistics

Threads
1,214,980
Messages
6,122,563
Members
449,088
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top