Date Range Search Across multiple tabs?

rowan853

New Member
Joined
Dec 27, 2010
Messages
10
Can anyone help?

What I'm trying to achieve.

I have an excel sheet which has an undefined number of tabs/worksheets (could be 50 and tomorrow 55).

I want to have a master page where i can enter a To and From date.
The code would then loop through every tab
For every tab where the date cell in column I is between my To/From date, return the full row in the master list (repeat)

*there may be tabs where there are multiple matches so it may return two rows from tab x

Any help would be greatly appreciated
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Update the following data in the macro:
- Set sh1 = Sheets("Master") 'Name of Master Sheet
- Case sh1.Name, "Report", "etc" 'These sheets will not be included

The From and To dates must be captured in A2 and B2
The data in the "Master" sheet should be like this:
Dante Amor
ABCDEFGHIJ
1Date FromDate To
204-jun10-jun
3
4HeaderHeaderHeaderHeaderHeaderHeaderHeaderHeaderHeaderHeader
5
Master

The results from row 5 down.

Try this:
VBA Code:
Sub FiterDates()
  Dim sh As Worksheet, sh1 As Worksheet
  Dim lr As Long, lr1 As Long
  
  Set sh1 = Sheets("Master")    'Name of Master Sheet
  sh1.Rows("5:" & Rows.Count).ClearContents
  
  For Each sh In Sheets
    Select Case sh.Name
      Case sh1.Name, "Report", "etc"    'These sheets will not be included
      
      Case Else
        If sh.AutoFilterMode Then sh.AutoFilterMode = False
        lr = sh.Range("I" & Rows.Count).End(3).Row
        sh.Range("I1:I" & lr).AutoFilter 1, _
          ">=" & Format(sh1.Range("A2").Value, "mm/dd/yyyy"), xlAnd, _
          "<=" & Format(sh1.Range("B2").Value, "mm/dd/yyyy")
        
        lr1 = sh1.Range("I" & Rows.Count).End(3).Row + 1
        sh.Range("I2:I" & lr).EntireRow.Copy sh1.Range("A" & lr1)
    End Select
  Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,588
Members
449,089
Latest member
Motoracer88

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