I always do things the easy way. If you ever wanted to use the number 2, then you'd have to recode all the statements to do it, which doesn't make sense.
There might be an easier way, but I would just use a cell that is a flag to whether your number is there or not, and then count the numbers, and the flags.
I did this, and formatted it as a percentage with 0 decimal places
Place the active cell in the column and one row above the row data to be filtered.
Data > Filter > Autofilter. Then click on the combo box that appears and you get a choice of many options: filter by a particular unique
content, Top 10, All, Custom, Sort Asc, Sor Desc, etc.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
You should use the COUNTIF() function for this. You can get it to count only the values which meet a certain criteria then use the COUNT() function to find the total number of cells in the range.
Highlight the range of cells you want to include in your formula and go to Insert->Name call the range numbers.
Find the cell where you want to calculate the percentage and enter the following formula.
Code:
=COUNTIF(numbers,1)/COUNT(numbers)
Format the cell as a percentage type by right clicking and clicking Format Cells
You should use the COUNTIF() function for this. You can get it to count only the values which meet a certain criteria then use the COUNT() function to find the total number of cells in the range.
Highlight the range of cells you want to include in your formula and go to Insert->Name call the range numbers.
Find the cell where you want to calculate the percentage and enter the following formula.
Code:
=COUNTIF(numbers,1)/COUNT(numbers)
Format the cell as a percentage type by right clicking and clicking Format Cells
Its just an easier way of specifying a range of cells. Highlight the cells you want to include in the range and then goto Name->Define in the Insert menu. You should then get a dialog box which enables you to give the range a name.