Home > Excel Tutorial > Filtering Between Two Dates

Filtering Between Two Dates

        We  have  created combo boxes containing  dates that unique ascending order sorted . For this process we have used Ado Connection. The dates in Column B were populated into two combo boxes.

Also ,we have added the following code to enter only date (as “dd.mm.yyyy”) in the Column B :

Private Sub Worksheet_Change(ByVal Target As Range)

Dim rng1 As Range, rng2 As Range

      If Intersect(Target, Range(“B:B”)) Is Nothing Then Exit Sub

    If Target.Address = “$B$1” Then Exit Sub

    For Each rng2 In Range(Target.Address)

    If rng2.Value = “” Then

    MsgBox “You Must Enter A Valid Date (20.10.2015 etc.)”, vbCritical, “”


    Exit Sub

    End If

        If IsDate(rng2.Value) = False Then

         rng2 = Empty

        Exit Sub


            rng2.Value = CDate(rng2)

        End If

    Next rng2

End Sub

Example File Can Be Downloaded Here

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: