jeudi 30 juillet 2015

Excel 2010 Formula to replace numbers

I have a list of results that may return a decimal value between 0 and 5. For business purposes I need to force Excel to replace the number as follows:

  • Any decimal value between 0 and 1 needs to show as the whole number 0
  • Any decimal value between 1 and 2 needs to show as the whole number 1
  • Any decimal value between 2 and 3 needs to show as the whole number 2
  • Any decimal value between 3 and 4 needs to show as the whole number 3
  • Any decimal value between 4 and 4.5needs to show as the whole number 4
  • Any decimal value between 4.5 and 5 needs to show the actual decimal value.

So, if the decimal value is 1.5, I want Excel to show it in the cell as 1. Or, if the decimal value is 4.5, I want excel to show it as 4.5.

I've tried using the following nested IF function (in this example the number to replaces is in cell L28):

=IF(L28>=4.5,L28,IF(L28<4.5>=4,"4",IF(L28=4,"4",IF(L28<4>=3,"3",IF(L28<2>=1,"2",IF(L28<1>=0,"0"))))))

However for some reason it works on values 4 or greater, but for anything <4 still shows 4, and I can't figure out why.

Should I be doing this in VBA instead?

Thanks in advance, and I'm hoping I explained this clearly...

Aucun commentaire:

Enregistrer un commentaire