VBA percentage code required

  • I assume you are talking about the Pass & Fail in column I of sheet 2.


    Quote

    There are 2 types I need, one has total, pass and fail, the others just pass and fail.


    Not sure what you mean by that, please explain.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • OK I see it now, try this

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Thanks KJ, unfortunately I'm a rank beginner and I can't get it to work.


    Is your code calculating the percentages required in column G, or just converting the number to a percentage format after the number is calculated?


    Also, I assume it is not calculating all the other cells I require.


    Cheers, cobber

  • You had column G formatted as Number with zero decimal places so my code just puts a number in column G which represents the percentage of Passes out of Total.


    Ahh you mean you need all the % columns on Sheet 1 calculating?

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • It is not clear what the % column in the "KPI 14 - Notice management" table is to be a percentage of what out of what?

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • I meant forget KPI 14 part.


    And yes, I need all the % columns on Sheet 1 calculating?


    I got this to work for J column and the other smaller calculations but it is a very long way to do it and it gives #DIV/0! when there is no data to calculate.


    Code
    Range("J5").Select
    ActiveCell.FormulaR1C1 = "=(RC[-2]/(RC[-2]+RC[-1]))*100"
  • Try the attached, click the button to calculate all the percentages (except KPI14).


    Code assigned to the button is

  • Note I changed the Formatting of all the percentage cells to Percentage with 0 decimal places.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • You're welcome.

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!