# Simplified IF statement

#### manc

##### Active Member
Good morning Demigods,

Can the following IF statement be shortened at all?

=IF(CO10<>0,IF(MONTH(O1)=1,O3,IF(MONTH(O1)=2,S3,IF(MONTH(O1)=3,W3,IF(MONTH(O1)=4,AA3,IF(MONTH(O1)=5,AE3,IF(MONTH(O1)=6,AI3,IF(MONTH(O1)=7,AM3,IF(MONTH(O1)=8,AQ3,IF(MONTH(O1)=9,AU3,IF(MONTH(O1)=10,AY3,IF(MONTH(O1)=11,BC3,IF(MONTH(O1)=12,BG3)))))))))))),IF(MONTH(O1)=1,O4,IF(MONTH(O1)=2,S4,IF(MONTH(O1)=3,W4,IF(MONTH(O1)=4,AA4,IF(MONTH(O1)=5,AE4,IF(MONTH(O1)=6,AI4,IF(MONTH(O1)=7,AM4,IF(MONTH(O1)=8,AQ4,IF(MONTH(O1)=9,AU4,IF(MONTH(O1)=10,AY4,IF(MONTH(O1)=11,BC4,IF(MONTH(O1)=12,BG4)))))))))))))

Depending on what month is in cell O1, it takes the value from O3 if O1=1, S3 if O1=2, W3 if O1=3 etc....

I'm looking to use this formula as part of a bigger one, so having this formula as small and as simple as possible would be a great help.

Any help/suggestions much appreciated.

Best regards
manc

### Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

#### FormR

##### MrExcel MVP
Hi, you could try.

`=INDEX(O3:BG4,IF(CO10<>0,1,2),((MONTH(O1)-1)*4)+1)`

#### Yongle

##### Well-known Member
or use CHOOSE instead of IF

exaample
=IF(MONTH(O1)=1,O3,IF(MONTH(O1)=2,S3,IF(MONTH(O1)=3,W3,IF(MONTH(O1)=4,AA3,IF(MONTH(O1)=5,AE3,IF(MONTH(O1)=6,AI3,IF(MONTH(O1)=7,AM3,IF(MONTH(O1)=8,AQ3,IF(MONTH(O1)=9,AU3,IF(MONTH(O1)=10,AY3,IF(MONTH(O1)=11,BC3,IF(MONTH(O1)=12,BG3))))))))))))
same as
=CHOOSE(MONTH(O1),O3,S3,W3,AA3,AE3,AI3,AM3,AQ3,AU3,AY3,BC3,BG3)

#### snjpverma

##### Well-known Member
Hi, you could try.

`=INDEX(O3:BG4,IF(CO10<>0,1,2),((MONTH(O1)-1)*4)+1)`
Wow, this is pure genius.

I was trying to solve it myself but I couldn't figure out this part "(MONTH(O1)-1)*4)+1"..
Loved it.

#### manc

##### Active Member
Guys, thanks very much for your quick responses.

Thank-you FormR for:
=INDEX(O3:BG4,IF(CO10<>0,1,2),((MONTH(O1)-1)*4)+1)

Exactly what i was looking for.
Thank-you Yongle also.

Best regards
manc

#### jasonb75

##### Well-known Member
Not an improvement, but a slight variation of FormR's suggestion so that you can see different ways to achieve the same result.

=INDEX(L3:BG4,1+(C10<>0),MONTH(O1)*4)

1,095,172
Messages
5,442,823
Members
405,199
Latest member
mkarnout

### This Week's Hot Topics

• Copy entire row if CountA <>0 to another sheet
[B]I want to copy entire row if CountA <>0 for column J7:AM7 (headers on J6:AM6) and so on till the last used cell is column D and paste the...
• Select last used Row in Table
I have created a Table in a Worksheet which is locked to prevent user errors and protect formula. Some of the cells require freetext entries which...
• excel workbook: do not allow certain file name
Hello all, Don't think this has ever been asked before, but how do I restrict file save [Before_Save Event] if the name of the file being saved...
• fixing problem autofilter
hello i need help about my code when i search by code in textbox it doesn't show anything this is my data [ATTACH type="full"...
• “Weight”
Hi, i’ve got a long sheet filled with weights such as kg,g,L & ml. i can build a formula to convert kg into g and liter into ml. How ever, my...
• How to capitalize everything before a certain character?
In column A, I have some text: Hello good day.mp3 Hello good day.flac etc. I'd like to capitalize everything before the period. I don't need the...