Adding OR to if formula

Brew

Well-known Member
Joined
Sep 29, 2003
Messages
1,569
How do i update the following formula to add, OR if L6=0, then result is 5:
=IF(L6=4,1,MOD(L6+2,5))
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Yogi Anand

MrExcel MVP
Joined
Mar 12, 2002
Messages
11,454
How do i update the following formula to add, OR if L6=0, then result is 5:
=IF(L6=4,1,MOD(L6+2,5))

Hi dk:

One way would be to use ...

=IF(L6,IF(L6=4,1,MOD(L6+2,5)),0)

However, I hope you are not anticipating L6+2 resulting in becoming negative, because MOD() does not seem to work well then -- so in that case, I would suggest using ...

=IF(L6>0,IF(L6=4,1,MOD(L6+2,5)),0)
 

Brew

Well-known Member
Joined
Sep 29, 2003
Messages
1,569
Yogi, neither solution met the desired result. The problem is the result can only be 1, 2, 3, 4, or 5, so in L7 increased the result from L6 by adding +2, however if L6=4, then L7=1 or if L6=5, then L7=2
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
49,473
Office Version
  1. 365
Platform
  1. Windows
Yogi, neither solution met the desired result. The problem is the result can only be 1, 2, 3, 4, or 5, so in L7 increased the result from L6 by adding +2, however if L6=4, then L7=1 or if L6=5, then L7=2
Brew, can you set out more clearly what the possible values in L6 can be and what the corresponding results you want are?
Is the formula only going to apply to L6? .. or will it be copied down or across?
 

Brew

Well-known Member
Joined
Sep 29, 2003
Messages
1,569

ADVERTISEMENT

The formula will be copied down and will not apply only to L6.
example:
L6=1, THEN L7=3
L6=2, THEN L7=4
L6=3, THEN L7=5
L6=4, THEN L7=2
L6=5, THEN L7=1
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
49,473
Office Version
  1. 365
Platform
  1. Windows
Brew

Try this
=CHOOSE(L6,3,4,5,2,1)
 

Forum statistics

Threads
1,136,926
Messages
5,678,610
Members
419,776
Latest member
mikelowski

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top