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

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
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,222,043
Messages
6,163,565
Members
451,844
Latest member
ddnndd1234

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