=if(and( Errors

jhorness

New Member
Joined
Sep 13, 2007
Messages
25
This is the formula I have so far...

=ROUND(IF(B4="",0,IF(AND(F4>=22,F4<49),1,IF(AND(F4>=49,F4<77),2,IF(AND(F4>=77,F4<105),3,IF(AND(F4>=105,F4<133),4,IF(AND(F4>=133,F4<161),5,F4/28)))))),0)

The formula I have above works fine, except when I try to add another =if(and( statement, I get an error message because I think I have too many And statements. I need to add 7 more statement for the remainder of the months in a year, 6 - 12.

Any idea on how I can fix this? Thanks
 

Some videos you may like

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Jonmo1

MrExcel MVP
Joined
Oct 12, 2006
Messages
44,061
A common method to replace this structure...
IF(AND(F4>=22,F4<49),1,IF(AND(F4>=49,F4<77),2,IF(AND(F4>=77,F4<105),3,IF(AND(F4>=105,F4<133),4,IF(AND(F4>=133,F4<161),5

is
LOOKUP(F4,{0,22,49,77,105,133,161},{0,1,2,3,4,5,0})

assuming numbers Less than 22 or Greater than 160 should return a 0

Hope that helps..
 

gnaga

Well-known Member
Joined
Jul 9, 2002
Messages
680
Office Version
  1. 365
  2. 2016
  3. 2013
Platform
  1. Windows
I think you can nest only 7 IFs more than taht you may not be able to add. Check with Help

TIA
GNaga
 

Watch MrExcel Video

Forum statistics

Threads
1,122,820
Messages
5,598,297
Members
414,224
Latest member
Crazy_FC

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