Reputation: 11
I have an excel sheet to filter a Column. The column relates to total experience of a person. The values are like 5years 2Months, 32Years 6Months etc... all the values are in String format. I need the following functionality.
Can anyone help..? I just need a way to do this.
Upvotes: 1
Views: 470
Reputation: 35915
Consider the following screenshot. Column a has the unfortunate text with years and months.
Column B splits out the years. Column C splits out the months. Column D has the total number of months for the time frame. With this in place, you can filter by any of the columns using the filter options of the Autofilter built into an Excel table.
The formulas are as follows:
Years: =MID([@total],1,FIND("Years",[@total])-1)+0
Months: =MID(SUBSTITUTE([@total],"Months",""),FIND(" ",[@total])+1,99)+0
Duration in months: =([@years]*12)+[@months]
Now just use the filters in the drop down butttons of the column headers and there is no need for VBA at all.
Upvotes: 3