Dear All,
I am creating a pivot table of the top 5 reasons for people calling us, I have the pivot table showing only the top 5 reasons, I have then created a formula to count how many cases we have and then another formula to calculate the % of each one of the top 5 against the overall cases logged,
Here is coding for this bit.
Range("h1"
.Value = "=COUNTA(A2:A65536)" 'counts all the records
Range("h5"
.Value = "=IF(E5=""Grand Total"","""",IF(AND _(E5>""*total"",G5>0),G5/$H$1,""""
)" ' does the count for each total line
Range("h5"
.Copy
Range("h6:h100"
.PasteSpecial xlPasteFormulas ' copies and paste's formula.
Once the formula is in place it will only count column g values that have Total at the end of column e, except for the grand total.
What I now need to do is count the values that make up the total for the % above, and calculate as a % against the total for each individual top 5, the problem I have is that each top 5 record could have either 1 - 20 categories, and I don't know where the total line will be is there a way to do this using coding as I can't find out a the formulas to do this.
a brief example of how the sheet looks
reasons 15 ' cases logged
reason 1 5
reason 2 6
reasons total 11 73.33%
Thanks for any suggestions and help, I have looked at field settings in the pivot table but I am unsure of this.
Thanks
Thanks Rob.![[yoda] [yoda] [yoda]](/data/assets/smilies/yoda.gif)
I am creating a pivot table of the top 5 reasons for people calling us, I have the pivot table showing only the top 5 reasons, I have then created a formula to count how many cases we have and then another formula to calculate the % of each one of the top 5 against the overall cases logged,
Here is coding for this bit.
Range("h1"
Range("h5"
Range("h5"
Range("h6:h100"
Once the formula is in place it will only count column g values that have Total at the end of column e, except for the grand total.
What I now need to do is count the values that make up the total for the % above, and calculate as a % against the total for each individual top 5, the problem I have is that each top 5 record could have either 1 - 20 categories, and I don't know where the total line will be is there a way to do this using coding as I can't find out a the formulas to do this.
a brief example of how the sheet looks
reasons 15 ' cases logged
reason 1 5
reason 2 6
reasons total 11 73.33%
Thanks for any suggestions and help, I have looked at field settings in the pivot table but I am unsure of this.
Thanks
Thanks Rob.
![[yoda] [yoda] [yoda]](/data/assets/smilies/yoda.gif)