Nested If Statements

Chomper

Board Regular
Joined
Apr 29, 2014
Messages
52
This statement works fine:
=IF(MID(F28,5,2)="PR",G28,IF(MID(F28,5,2)="PF",G28,0))

But I needed to add some extra checks so I wrote this:
=IF(MID(F28,5,2)="PR",G28,IF(MID(F28,5,2)="PF",G28,if(mid(f28,4,2)=”PR”,g28,if(mid(f28,4,2)=”PF”,g28,0))))

But now I get the #Name? error.

Any idea why?

I'm trying to find entries that have a .PF or .PR in them:
ie.
return true for BMO.PR.L
return true for BMO.PF.C
return true for BAM.PR.T
return true for CM.PR.O
return false for ENB
return false for DRA.UN
return false for DH.DB

the additional formula was to catch the CM.PR.O as the first formula did not recognize this as being true as it was looking at the wrong 2 characters (with my formula it would see 'R.' instead of the 'PR').

Thanks,
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
=IF(MID(F28,5,2)="PR",G28,IF(MID(F28,5,2)="PF",G28,if(mid(f28,4,2)=PR,g28,if(mid(f28,4,2)=PF,g28,0))))

I don't know why it happens, but I see it quite often here
You've got some weird quote marks in there

Should be
Code:
=IF(MID(F28,5,2)="PR",G28,IF(MID(F28,5,2)="PF",G28,IF(MID(F28,4,2)=[B][COLOR=#b22222]"[/COLOR][/B]PR[B][COLOR=#b22222]"[/COLOR][/B],G28,IF(MID(F28,4,2)=[B][COLOR=#b22222]"[/COLOR][/B]PF[B][COLOR=#b22222]"[/COLOR][/B],G28,0))))
 
Upvote 0
Hi

Try this on for size:

Code:
=IF(SUM(COUNTIF(F28,{"*.PR*","*.PF*"})),G28,0)

Mackers

Edit: changed PR to .PR in line with your initial post
 
Upvote 0
I don't know why it happens, but I see it quite often here
You've got some weird quote marks in there

Should be
Code:
=IF(MID(F28,5,2)="PR",G28,IF(MID(F28,5,2)="PF",G28,IF(MID(F28,4,2)=[B][COLOR=#b22222]"[/COLOR][/B]PR[B][COLOR=#b22222]"[/COLOR][/B],G28,IF(MID(F28,4,2)=[B][COLOR=#b22222]"[/COLOR][/B]PF[B][COLOR=#b22222]"[/COLOR][/B],G28,0))))

I see. I wrote the original formula in excel. Then we I was adding to it I had copied it and pasted to a word document, added the additional formula and then copy and pasted back into excel.

I changed the weird quotes in excel and it works perfect.

Thanks.
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,939
Members
449,094
Latest member
teemeren

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
Back
Top