Snow
Snow

Reputation: 50

Rounding numbers in complex conditions in Excel formula

I need to round up/down the numbers (last 2 digits, no decimal) based on three conditions:

  1. if 00, then -1
  2. if 01 to 49, then round up to 50
  3. if 51 to 98, then round up to 99

examples:

..................

Upvotes: 0

Views: 3189

Answers (2)

Jon Egerton
Jon Egerton

Reputation: 41539

Try this. (Its quite nice apart from the fudge at the end for the 0 case):

=(CEILING(A1/50,1)*50)-IF(MOD(FLOOR((A1-1)/50,1),2)=1,1,0)

In explanation:

  1. (CEILING(A1/50,1)*50) rounds up to the next 50
  2. IF(MOD(FLOOR(A1/50,1),2)=1,1,0) takes off 1 if the number is large than an odd multiple of 50

Upvotes: 1

Tim Perry
Tim Perry

Reputation: 3096

assume value is in a1

=IF(MOD(A1,100)=0,A1-1,IF(MOD(A1,100)<51,A1+50-MOD(A1,100),A1+99-MOD(A1,100)))

Upvotes: 3

Related Questions