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:

```
=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 ?

### Answer：

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!

Tags: excelexcel, vba