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
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
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),"")
 
Upvote 0
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:
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,243
Members
448,555
Latest member
RobertJones1986

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