Hello,
I need to add a Macro into a workbook to allow users to filter various data down to date ranges. The users have a couple of drop down boxes to put a From and a To date into Excel. I then want to give them a button to press to apply a filter to the date and display just data that is dated on and between the to a from dates that I have allowed them to select.
I have written my Marco and it works for a single date, but I do not know how to amend it so that it applies to all dates that are between the two date ranges.
Currently it only works if both teh 'To' and the 'From' dates are the same...
This is the VBA so far, quite simple and I am sure an amendment to it is simple also, I am just not sure what it is to do it, so hopefully someone can advise....
Dim fromDate As String
Dim toDate As String
Dim userName As String
Dim ptype As String
LR = Range("A" & Rows.Count).End(xlUp).Row
fromDate = Range("A3").Value
toDate = Range("A4").Value
userName = Range("A5").Value
ptype = Range("A6").Value
If ActiveSheet.AutoFilterMode = True Then ActiveSheet.AutoFilterMode = False
Rows("10:10").Select
Selection.AutoFilter
ActiveSheet.Range("$A$10:$O$" & LR).AutoFilter Field:=1, Criteria1:=fromDate
ActiveSheet.Range("$A$10:$O$" & LR).AutoFilter Field:=2, Criteria1:=toDate
ActiveSheet.Range("$A$10:$O$" & LR).AutoFilter Field:=5, Criteria1:=userName
ActiveSheet.Range("$A$10:$O$" & LR).AutoFilter Field:=6, Criteria1:=ptype
Apologies - My browser is not behaving today and has not given me the full web content - hence why my code is not in Code Brackets.
Bookmarks