How To Find Data Between Two Dates In Excel Vba ?

How To Find Data Between Two Dates In Excel Vba?

Expert Asked on June 18, 2017 in Excel.
Add Comment
1 Answer(s)

I found a solution like this :

Records in between two specific dates easily can be filtered using drop-down lists . Drop-down lists were filled with unique values as ascending order using Ado connection. Thus, it is easier to choose between the dates on the worksheet.

The filtered data can be copied to other sheet if it wished.

lngStart = VBA.CDate(Sheets("Page1").ComboBox1) 'assume this is the start date
lngEnd = VBA.CDate(Sheets("Page1").ComboBox2) 'assume this is the end date
If lngStart > lngEnd Then
MsgBox "The Start Date Can Not Be Bigger Than The End Date.", vbCritical, ""
Exit Sub
End If
Sheets("Page1").Range("B:B").AutoFilter field:=1, _
Criteria1:=">=" & lngStart, Operator:=xlAnd, Criteria2:="<=" & lngEnd

Watch the video to see how it’s done  and download example file :″>

Expert Answered on August 10, 2017.
Add Comment
  • Found this useful?

    Please share using the share button above.

    If you found the answer is best answer for your question, Please mark as 'best answer' by clicking on the right tick mark icon at the left side of the answer.

    Found the answer useful and wants to credit the user, then vote the answer (vote up).

  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.