Please could someone post how to search for text and dates within a database. I have a spreadsheet that can search for any part of text but I cannot search by date.
The existing code is as follows:
Private Sub Search_Click()
Dim LR As Long, Val As String, cell As Range, Rng As Range, Code As Boolean
Dim dSh As Worksheet, v
'Setup
Sheets("SEARCH-HERE").Activate
If Range("E2") <> "" Then
Val = Range("E2").Value & ""
Code = True
ElseIf Range("E3") <> "" Then
Val = Range("E3").Value
Code = False
Else
MsgBox "Please enter ONE search criteria and try again."
Exit Sub
End If
Application.ScreenUpdating = False
Application.EnableEvents = False
Set dSh = Sheets("DATABASE")
Range("B10:J200").ClearContents
'Transfer matching data
LR = dSh.Range("A" & Rows.Count).End(xlUp).Row
dSh.Range("A2").AutoFilter
dSh.Range("A2").AutoFilter Field:=1, Criteria1:="=*" & Val & "*"
dSh.Range("B2:J" & LR).SpecialCells(xlCellTypeVisible).Copy Range("B9")
dSh.Range("A2").AutoFilter
Any help would be appreciated.
Thanks,
Stewart
Bookmarks