Home » excel » excel – calculate the percentage in VBA

excel – calculate the percentage in VBA

Posted by: admin May 14, 2020 Leave a comment


Hi I want to calculate the percentage of this columns:


I used this formula for calculating the percentage of order_units of all units if auction_id is the same:


it’s for auction_id = 20 but for auction_id=19 i changed the formula :


and so on…

I have more than 200 rows if there any easy way to do that with formula or vba code ?

How to&Answers:

Use SUMIF to get the total:


enter image description here


If I understand you question correctly a nested if statement would suit your needs.

An example is:


If you want to see how this works just put 3 in cell A1 and 4 in cell B1 and then this formula in cell C1 and you should get .75

Also, you can use google and YouTube for further help. If this was not what you are asking then I hope you get a helpful comment!