Find Row Between Two Dates Excel Wookbook

I have an Excel Workbook with 8 tabs. I would like to find all the rows (records) between two dates and put the resulst on a seperate tab (entire row).
Who is Participating?
gowflowConnect With a Mentor Commented:
Well having not answered my questions, I made up a sample workbook with Dates in Col A and here is the code for that

Sub GetData()
Dim WS As Worksheet
Dim WSResult As Worksheet
Dim sDate As String, eDate As String
Dim MaxRow As Long

If MsgBox("This process will lookup all sheets in this workbook for a date range in Col A and will return in this sheet all the rows where the data falls in between the selected dates." & Chr(10) & Chr(10) _
    & "Are you ready to proceed ?", vbQuestion + vbYesNo, "Get Data") = vbYes Then
    Set WSResult = Sheets("Results")
    '---> Start Date
        sDate = InputBox("Input starting Date: ", "Start Date", Format(Now, "mm/dd/yyyy"))
    Loop Until IsDate(sDate)
    '---> End Date
        eDate = InputBox("Input ending Date: ", "End Date", Format(Now, "mm/dd/yyyy"))
    Loop Until IsDate(eDate)
    For Each WS In ActiveWorkbook.Worksheets
        If WS.Name <> "Results" Then
            '---> Filter the data as per dates
            WS.UsedRange.AutoFilter field:=1, Criteria1:=">=" & sDate, Operator:=xlAnd, Criteria2:="<=" & eDate
            If WS.Rows.End(xlDown).Row < 1048576 Then
                '---> first time put the header
                If MaxRow = 0 Then
                    WS.Range("1:1").Copy WSResult.Range("A1")
                    MaxRow = 2
                End If
                WS.Range("A2", "A" & WS.Rows.End(xlDown).Row).EntireRow.SpecialCells(xlCellTypeVisible).Copy
                WSResult.Range("A" & MaxRow).PasteSpecial
                MaxRow = WSResult.UsedRange.Rows.Count + 1
            End If
        End If
    Next WS
    '---> Advise user
    If MaxRow - 2 = 0 Then
        MsgBox ("No rows were found in the date range " & sDate & " - " & eDate)
        MsgBox ("A total of " & MaxRow - 2 & " rows were found in the date range " & sDate & " - " & eDate & " and copied successfully.")
    End If
End If

End Sub

Open in new window

the attached sample workbook is for you to see how it works.
Activate macros and press on the button in sheet Results. Put dates interval when required as start and end date. It verify that dates are indeed dates and not strings or non dates. then it goes thru all the sheets and give the results in sheet Results.

Let me know
could you upload a sample ?
Were are your dates lying ? in what column ? all in the same Column ?
Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

shieldscoAuthor Commented:
I was at lunch - yes the dates are all in the same column -- I will test your code
shieldscoAuthor Commented:
Works Great - Thanks
your welcome.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.