This Excel macro filters a set of data in Excel and displays only the top X percent of that data. This means the highest X percent of that data will be displayed and you will choose which column to use to make that comparison to determine the top X percent within the macro. Also, the great thing about this macro is that you get to decide what percentage you want to use; you are not limited to just using 10 percent.
To use this macro, replace the "#" with the actual percent that you would like to display. Make sure to type the percent as a whole number and not a decimal; in other words input the percent as an integer without decimal places. Even though this macro uses the xlTop10Percent operator, that still applies when filtering for percentages other than 10 percent. The last thing to do is to adjust the range and field parameters to fit your data set or table in Excel.
All of the elements below often appear within autofilter macros.
Range
Field
Criteria
Operator
Sub AutoFilter_Top_X_Percent_Items()
'Replace the "#" sign with the top percentage of items you would like to have displayed
Range("A1").AutoFilter Field:=1, Criteria1:="#", Operator:=xlTop10Percent
End Sub