Problems with iserror function

jimmy2times

Board Regular
Joined
Aug 8, 2014
Messages
69
Hi Everyone,

I am working on an exercise where I am extracting the middle name from a list of names by locating the space characters in the text string. There are some entries with middle names and some without middle names. When there is no middle name I want to replace the #value error with a zero length string. See the example below

Sales ManagerFirst SpaceSecond SpaceLenFirst NameMiddle Name
John Paul Smith51015JohnPaul
Bob Harris4#VALUE!10Bob#VALUE!

<tbody>
</tbody>
Obviously there is no middle name for Bob Harris.

The formula I am using is

=IF(ISERROR(A3),"",MID(A3,B3+1,C3-B3))

I am getting the correct result for John Paul Smith but want to return "" for Bob Harris.

Why am I still getting the #value! error?

Any help would be much appreciated!

Jimmy
 

Some videos you may like

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

BarryL

Well-known Member
Joined
Jan 20, 2014
Messages
1,421
I think you mean to use the below


=IF(ISERROR(MID(A3,B3+1,C3-B3)),"",MID(A3,B3+1,C3-B3))

better to use

=IFERROR(MID(A3,B3+1,C3-B3),"")
 

godsaaint

Active Member
Joined
Sep 16, 2016
Messages
285
The problem is you are using the ISERROR formula with the names, so in your example ISERROR(A3) is basically ISERROR("Bob Harris") which is not an error, so it say FALSE, and run MID(A3,B3+1,C3-B3), which will get you an error. Just change the reference in ISERROR(A2/A3) to ISERROR(C2/C3), so when you get an error in column C because there isn't a second space, the formula will return blank ("")

EDIT: Alternatively, I also recommend the formulas posted by Barry and cnestg8r.
 
Last edited:

jimmy2times

Board Regular
Joined
Aug 8, 2014
Messages
69

ADVERTISEMENT

Thanks Barry, much appreciated
 

FDibbins

Well-known Member
Joined
Feb 16, 2013
Messages
6,723
Another way would be to count the spaces, and base the calc on that...

=LEN(K5)-LEN(SUBSTITUTE(K5," ",""))
K​
L​
5​
aaa bbb ccc
2​
6​
aaa bbb
1​
So if the answer is 1, then there are only 2 names
 

Watch MrExcel Video

Forum statistics

Threads
1,122,518
Messages
5,596,631
Members
414,082
Latest member
sasmita

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