Autofiltering based on cell contents

CrashBandicoot

New Member
Joined
Oct 16, 2017
Messages
8
Hi,

I'll say upfront I'm not the worlds best Vba person but I've gotten really good at frankenstiening and modifying existing code. I plan to learn more but there just don't seems to be enough hours on the day.

Anyway:
I've hit a bit of a snag with a macro I'm building and i was hoping someone might be able to lend a hand.

Background:

Say I have two worksheets- alpha & beta. Alpha is a data entry tool that I'm trying to build out some tools to make my life easier and speed up the reporting process. Beta is the data table and has Data in columns A through W. Column A alway has information in it, and column W contains what team the information in the row pertains too.

Column A is a date column with the format mm/dd/yyyy. Column W always has a text value

Sheet beta has an ever growing number of rows as users add to it constantly.

Task:

I'd like to be able to have on sheet alpha say cell A10 have a start date, cell A11 have an end date, and cell A12 have the team (for ex. Team could ="ABC". When I run the macro I'd like it to filter the table on sheet beta to show rows within the date range and that relate to the specified team. Then copy those row values to a new sheet called Delta and then unfilter sheet beta.

I've got to manually filter everything currently and it's been slowing me down substantially when I'm pulling and compiling reports.

I'd sincerely appreciate any guidance. Happy to answer any questions. I don't really have any code that I've been working on for this as I've yet to come close to succeeding with it.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hi. See if this could help you.

Code:
Sub ReplicateFilteredData()
 Dim startDate As Date, endDate As Date, team As String
  startDate = Sheets("alpha").[A10]: endDate = Sheets("alpha").[A11]: team = Sheets("alpha").[A12]
  Application.ScreenUpdating = False
   With Sheets("beta")
    .AutoFilterMode = False
    .[A1].AutoFilter 1, ">=" & CLng(startDate), xlAnd, "<=" & CLng(endDate)
    .[A1].AutoFilter 23, team
    .Range("A2:W" & .Cells(Rows.Count, 1).End(xlUp).Row).Copy Sheets("Delta").Cells(Rows.Count, 1).End(3)(2)
    .AutoFilterMode = False
   End With
  Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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