FTh
FTh

Reputation: 61

calculate the percentage in VBA

Hi I want to calculate the percentage of this columns:

percentage

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

=IF((A2=A3),C2/D2)

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

=IF((A17=A18),C17/D$17)

and so on...

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

Upvotes: 1

Views: 720

Answers (2)

Nathan
Nathan

Reputation: 29

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

An example is:

=IF(A1<>B1,IF(A1>B1,A1*B1,A1/B1))

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!

Upvotes: 0

BigBen
BigBen

Reputation: 50162

Use SUMIF to get the total:

=C2/SUMIF(A:A,A2,D:D)

enter image description here

Upvotes: 2

Related Questions