![]() |
Filtering Dates in a table with input boxes
Hi,
I am trying to filter dates in a table based on two input box values...the start date and the end date... The only way I can see to do this is to enter the last day of the months that will be in the report...is there any way to make it so that the user can input specific dates to pull a report for those specific dates? This is what I came up with so far... MYFILTER1 = InputBox _ ("Please enter the first day of the period you would like to generate this report for:", _ "First Date") MYFILTER2 = InputBox _ ("Please enter the last day of the period you would like to generate this report for:", _ "End Date", range("J1")) ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, Operator:= _ xlFilterValues, Criteria2:=Array(1, MYFILTER1, 1, MYFILTER2) |
Filtering Dates in a table with input boxes
Try this:
ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, _ Criteria1:="=MYFILTER1,3", Operator:=xlAnd, _ Criteria2:="<=MYFILTER2" Tom "R Tanner" wrote: Hi, I am trying to filter dates in a table based on two input box values...the start date and the end date... The only way I can see to do this is to enter the last day of the months that will be in the report...is there any way to make it so that the user can input specific dates to pull a report for those specific dates? This is what I came up with so far... MYFILTER1 = InputBox _ ("Please enter the first day of the period you would like to generate this report for:", _ "First Date") MYFILTER2 = InputBox _ ("Please enter the last day of the period you would like to generate this report for:", _ "End Date", range("J1")) ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, Operator:= _ xlFilterValues, Criteria2:=Array(1, MYFILTER1, 1, MYFILTER2) |
Filtering Dates in a table with input boxes
If you need the date of the last day in the month of the date the user
inputs, give this a try... MYFILTER1 = InputBox("Please enter the first day of the period " & _ "you would like to generate this report for:", "First Date") If IsDate(MYFILTER1) Then MYFILTER1 = DateSerial(Year(MYFILTER1), Month(MYFILTER1) + 1, 0) End If Rick "R Tanner" wrote in message ... Hi, I am trying to filter dates in a table based on two input box values...the start date and the end date... The only way I can see to do this is to enter the last day of the months that will be in the report...is there any way to make it so that the user can input specific dates to pull a report for those specific dates? This is what I came up with so far... MYFILTER1 = InputBox _ ("Please enter the first day of the period you would like to generate this report for:", _ "First Date") MYFILTER2 = InputBox _ ("Please enter the last day of the period you would like to generate this report for:", _ "End Date", range("J1")) ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, Operator:= _ xlFilterValues, Criteria2:=Array(1, MYFILTER1, 1, MYFILTER2) |
Filtering Dates in a table with input boxes
On Aug 15, 9:36 am, "Rick Rothstein \(MVP - VB\)"
wrote: If you need the date of the last day in the month of the date the user inputs, give this a try... MYFILTER1 = InputBox("Please enter the first day of the period " & _ "you would like to generate this report for:", "First Date") If IsDate(MYFILTER1) Then MYFILTER1 = DateSerial(Year(MYFILTER1), Month(MYFILTER1) + 1, 0) End If Rick "R Tanner" wrote in message ... Hi, I am trying to filter dates in a table based on two input box values...the start date and the end date... The only way I can see to do this is to enter the last day of the months that will be in the report...is there any way to make it so that the user can input specific dates to pull a report for those specific dates? This is what I came up with so far... MYFILTER1 = InputBox _ ("Please enter the first day of the period you would like to generate this report for:", _ "First Date") MYFILTER2 = InputBox _ ("Please enter the last day of the period you would like to generate this report for:", _ "End Date", range("J1")) ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, Operator:= _ xlFilterValues, Criteria2:=Array(1, MYFILTER1, 1, MYFILTER2) What I am really trying to do is get the first and last date of the period for the report from the user. Not necessarily just the last date...I'm not sure if I made that clear or not... Thanks for your input... |
Filtering Dates in a table with input boxes
I tried your idea with the filter 1 and 2 and the criteria but it did
not work...it didn't unselected everything in the table rather than just the specified dates... |
Filtering Dates in a table with input boxes
I erroneously included ,3. This should work better.
ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, _ Criteria1:="=MYFILTER1", Operator:=xlAnd, _ Criteria2:="<=MYFILTER2" "TomPl" wrote: Try this: ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, _ Criteria1:="=MYFILTER1,3", Operator:=xlAnd, _ Criteria2:="<=MYFILTER2" Tom "R Tanner" wrote: Hi, I am trying to filter dates in a table based on two input box values...the start date and the end date... The only way I can see to do this is to enter the last day of the months that will be in the report...is there any way to make it so that the user can input specific dates to pull a report for those specific dates? This is what I came up with so far... MYFILTER1 = InputBox _ ("Please enter the first day of the period you would like to generate this report for:", _ "First Date") MYFILTER2 = InputBox _ ("Please enter the last day of the period you would like to generate this report for:", _ "End Date", range("J1")) ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, Operator:= _ xlFilterValues, Criteria2:=Array(1, MYFILTER1, 1, MYFILTER2) |
Filtering Dates in a table with input boxes
The code should filter to show everything between the two dates inclusive.
Can't imagine why it doesn't work. "R Tanner" wrote: I tried your idea with the filter 1 and 2 and the criteria but it did not work...it didn't unselected everything in the table rather than just the specified dates... |
Filtering Dates in a table with input boxes
On Aug 15, 10:09 am, TomPl wrote:
I erroneously included ,3. This should work better. ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, _ Criteria1:="=MYFILTER1", Operator:=xlAnd, _ Criteria2:="<=MYFILTER2" "TomPl" wrote: Try this: ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, _ Criteria1:="=MYFILTER1,3", Operator:=xlAnd, _ Criteria2:="<=MYFILTER2" Tom "R Tanner" wrote: Hi, I am trying to filter dates in a table based on two input box values...the start date and the end date... The only way I can see to do this is to enter the last day of the months that will be in the report...is there any way to make it so that the user can input specific dates to pull a report for those specific dates? This is what I came up with so far... MYFILTER1 = InputBox _ ("Please enter the first day of the period you would like to generate this report for:", _ "First Date") MYFILTER2 = InputBox _ ("Please enter the last day of the period you would like to generate this report for:", _ "End Date", range("J1")) ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, Operator:= _ xlFilterValues, Criteria2:=Array(1, MYFILTER1, 1, MYFILTER2) it still didn't work...I have my filters declared as dates...That is how is should be right? |
Filtering Dates in a table with input boxes
On Aug 15, 10:09 am, TomPl wrote:
I erroneously included ,3. This should work better. ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, _ Criteria1:="=MYFILTER1", Operator:=xlAnd, _ Criteria2:="<=MYFILTER2" "TomPl" wrote: Try this: ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, _ Criteria1:="=MYFILTER1,3", Operator:=xlAnd, _ Criteria2:="<=MYFILTER2" Tom "R Tanner" wrote: Hi, I am trying to filter dates in a table based on two input box values...the start date and the end date... The only way I can see to do this is to enter the last day of the months that will be in the report...is there any way to make it so that the user can input specific dates to pull a report for those specific dates? This is what I came up with so far... MYFILTER1 = InputBox _ ("Please enter the first day of the period you would like to generate this report for:", _ "First Date") MYFILTER2 = InputBox _ ("Please enter the last day of the period you would like to generate this report for:", _ "End Date", range("J1")) ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, Operator:= _ xlFilterValues, Criteria2:=Array(1, MYFILTER1, 1, MYFILTER2) it still didn't work...I have my filters declared as dates...That is how is should be right? |
Filtering Dates in a table with input boxes
On Aug 15, 10:09 am, TomPl wrote:
I erroneously included ,3. This should work better. ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, _ Criteria1:="=MYFILTER1", Operator:=xlAnd, _ Criteria2:="<=MYFILTER2" "TomPl" wrote: Try this: ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, _ Criteria1:="=MYFILTER1,3", Operator:=xlAnd, _ Criteria2:="<=MYFILTER2" Tom "R Tanner" wrote: Hi, I am trying to filter dates in a table based on two input box values...the start date and the end date... The only way I can see to do this is to enter the last day of the months that will be in the report...is there any way to make it so that the user can input specific dates to pull a report for those specific dates? This is what I came up with so far... MYFILTER1 = InputBox _ ("Please enter the first day of the period you would like to generate this report for:", _ "First Date") MYFILTER2 = InputBox _ ("Please enter the last day of the period you would like to generate this report for:", _ "End Date", range("J1")) ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, Operator:= _ xlFilterValues, Criteria2:=Array(1, MYFILTER1, 1, MYFILTER2) it still didn't work...I have my filters declared as dates...That is how is should be right? |
Filtering Dates in a table with input boxes
On Aug 15, 10:09 am, TomPl wrote:
I erroneously included ,3. This should work better. ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, _ Criteria1:="=MYFILTER1", Operator:=xlAnd, _ Criteria2:="<=MYFILTER2" "TomPl" wrote: Try this: ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, _ Criteria1:="=MYFILTER1,3", Operator:=xlAnd, _ Criteria2:="<=MYFILTER2" Tom "R Tanner" wrote: Hi, I am trying to filter dates in a table based on two input box values...the start date and the end date... The only way I can see to do this is to enter the last day of the months that will be in the report...is there any way to make it so that the user can input specific dates to pull a report for those specific dates? This is what I came up with so far... MYFILTER1 = InputBox _ ("Please enter the first day of the period you would like to generate this report for:", _ "First Date") MYFILTER2 = InputBox _ ("Please enter the last day of the period you would like to generate this report for:", _ "End Date", range("J1")) ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, Operator:= _ xlFilterValues, Criteria2:=Array(1, MYFILTER1, 1, MYFILTER2) it still didn't work...I have my filters declared as dates...That is how is should be right? |
Filtering Dates in a table with input boxes
Sorry,
Replace this: ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, _ Criteria1:="=MYFILTER1", Operator:=xlAnd, _ Criteria2:="<=MYFILTER2" With this: ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, _ Criteria1:="=" & MYFILTER1, Operator:=xlAnd, _ Criteria2:="<=" & MYFILTER2 It was hard to test because I don't have your worksheet. Remember to enter the dates in a format that excel recognises as a date. MYFILTER1 & MYFILTER2 should be declared as dates. Hope this works. "R Tanner" wrote: On Aug 15, 10:09 am, TomPl wrote: I erroneously included ,3. This should work better. ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, _ Criteria1:="=MYFILTER1", Operator:=xlAnd, _ Criteria2:="<=MYFILTER2" "TomPl" wrote: Try this: ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, _ Criteria1:="=MYFILTER1,3", Operator:=xlAnd, _ Criteria2:="<=MYFILTER2" Tom "R Tanner" wrote: Hi, I am trying to filter dates in a table based on two input box values...the start date and the end date... The only way I can see to do this is to enter the last day of the months that will be in the report...is there any way to make it so that the user can input specific dates to pull a report for those specific dates? This is what I came up with so far... MYFILTER1 = InputBox _ ("Please enter the first day of the period you would like to generate this report for:", _ "First Date") MYFILTER2 = InputBox _ ("Please enter the last day of the period you would like to generate this report for:", _ "End Date", range("J1")) ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, Operator:= _ xlFilterValues, Criteria2:=Array(1, MYFILTER1, 1, MYFILTER2) it still didn't work...I have my filters declared as dates...That is how is should be right? |
Filtering Dates in a table with input boxes
On Aug 15, 2:19 pm, TomPl wrote:
Sorry, Replace this: ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, _ Criteria1:="=MYFILTER1", Operator:=xlAnd, _ Criteria2:="<=MYFILTER2" With this: ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, _ Criteria1:="=" & MYFILTER1, Operator:=xlAnd, _ Criteria2:="<=" & MYFILTER2 It was hard to test because I don't have your worksheet. Remember to enter the dates in a format that excel recognises as a date. MYFILTER1 & MYFILTER2 should be declared as dates. Hope this works. "R Tanner" wrote: On Aug 15, 10:09 am, TomPl wrote: I erroneously included ,3. This should work better. ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, _ Criteria1:="=MYFILTER1", Operator:=xlAnd, _ Criteria2:="<=MYFILTER2" "TomPl" wrote: Try this: ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, _ Criteria1:="=MYFILTER1,3", Operator:=xlAnd, _ Criteria2:="<=MYFILTER2" Tom "R Tanner" wrote: Hi, I am trying to filter dates in a table based on two input box values...the start date and the end date... The only way I can see to do this is to enter the last day of the months that will be in the report...is there any way to make it so that the user can input specific dates to pull a report for those specific dates? This is what I came up with so far... MYFILTER1 = InputBox _ ("Please enter the first day of the period you would like to generate this report for:", _ "First Date") MYFILTER2 = InputBox _ ("Please enter the last day of the period you would like to generate this report for:", _ "End Date", range("J1")) ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, Operator:= _ xlFilterValues, Criteria2:=Array(1, MYFILTER1, 1, MYFILTER2) it still didn't work...I have my filters declared as dates...That is how is should be right? Thank you Tom...you are awesome...this did work... |
Filtering Dates in a table with input boxes
Try EasyFilter
http://www.rondebruin.nl/easyfilter.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "R Tanner" wrote in message ... Hi, I am trying to filter dates in a table based on two input box values...the start date and the end date... The only way I can see to do this is to enter the last day of the months that will be in the report...is there any way to make it so that the user can input specific dates to pull a report for those specific dates? This is what I came up with so far... MYFILTER1 = InputBox _ ("Please enter the first day of the period you would like to generate this report for:", _ "First Date") MYFILTER2 = InputBox _ ("Please enter the last day of the period you would like to generate this report for:", _ "End Date", range("J1")) ActiveSheet.ListObjects("WDT").range.AutoFilter Field:=1, Operator:= _ xlFilterValues, Criteria2:=Array(1, MYFILTER1, 1, MYFILTER2) |
All times are GMT +1. The time now is 05:14 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com