I'm trying to create a formula (although I think it will need to be a macro). The table has 2 columns, column one has percentages. What needs to happen is whichever 3 rows have the lowest percentage column 2 needs to be changed to -3,-2 and -1. If a percentage is over 3% then make column 2 be 1. I have the over 3% working but not the bottom 3 percentages. Anyone point me in the right direction? Thanks!


For values in A in the percentage format:

=IF(COUNT(A:A)-COUNTIF(A:A,">"&A1)<= 3,
  • Thanks, I actually just found out the same thing, I was trying to use nested If's with VB syntax. Dec 7 '10 at 3:43

Since you've only got three levels to compare (min,max and middle), I think this can be accomplished with a nested if statements.

The rules I got from the above are: there three options: min which should be -1, max which should be -3 and middle which should be -2, unless the value is over 3%, then the value should be 1.

=if(a1 = min(A1:A3);(if (a1 > 3% ; 1; -1));if (a1 = max(A1:A3); (if(a1 > 3%; 1; -3));if(a1 > 3%; 1; -2))

The first if check for a min value, and then checks for the magic value of 3%. The else checks for the max value, then checks for the magic value. If it makes it to the second else, then its got to be the middle value. Compare it to the magic value of 3% and your done.

  • My final formula came out to be: =IF(B20=SMALL(B7:B21,1),-3, IF( B20=SMALL(B7:B21,2),-2, IF( B20=SMALL(B7:B21,2),-2, IF(B20=LARGE(B7:B21,1),3,IF(B20=LARGE(B7:B21,2),2,IF(B20=LARGE(B7:B21,3),1,IF(B20>=0.03,1,))))))) Dec 7 '10 at 3:44
  • Sorry, found an error in my own, fixed: =IF(B12=SMALL(B7:B21,1),-3, IF( B12=SMALL(B7:B21,2),-2, IF( B12=SMALL(B7:B21,3),-1,IF(B12>0, IF(B12=LARGE(B7:B21,1),3,IF(B12=LARGE(B7:B21,2),2,IF(B12=LARGE(B7:B21,3),1,IF(B12>=0.03,1,)))),0)))) There's a IF in there that wasn't originally mentioned in the question Dec 7 '10 at 4:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.