Forum Discussion
gwharvey
Oct 04, 2023Copper Contributor
Splicer on 2 columns
I have a bunch of parts for different vehicles that fit different years, actually a range of years. So I can easily make a splicer for make of vehicle or for what part, what I am having problems with is figuring out how to filter the year I'm looking for. The years came as a range 2008-2012 or 2019-2023 so what I did was split into min year and max year columns.
My ideal solution would be a Slicer that I could select a year and it would filter both columns to see if above the min year and below the max year.
I did make another column where I check both columns to a date I type in or pull down, just true or false and then filter but thats pretty clunky, not slick like a slicer.
Any suggestions?
- suraj786Copper Contributor
I understand your situation. You want to filter data based on a year range using a slicer in Excel.
Unfortunately, Excel slicers don’t directly support filtering by a range of values. However, there are some workarounds you can consider:
Helper Column: Create a helper column for each year within the range.
For example, if your range is 2008-2012, create columns for 2008, 2009, 2010, 2011, and 2012.
Mark each column with a ‘1’ if the year falls within the range and ‘0’ otherwise.
Then, you can use a slicer on these helper columns.
Pivot Table: Create a pivot table from your data and use a timeline slicer. This will allow you to filter by a range of dates.
VBA Macro: Write a VBA macro to create a custom slicer that filters based on your criteria. This requires some knowledge of VBA and might be more complex than the other solutions.
Remember to always back up your data before trying these solutions