MID / SEARCH error on the words "Spark" and "Park"

MrSamExcel

Board Regular
Joined
Apr 6, 2016
Messages
51
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Why does my formula in B5 and B6 break with the words "SPARK" and "PARK" (regardless of upper/lower case)? As you can see, replacing SPARK with SARK works fine. I think the issue lies in the MID part of the formula because it generated a result when I just used the SEARCH and LEN parts.

Excel 2013 64 bit
[Table="width:, class:head"][tr=bgcolor:#888888][th] [/th][th]
A
[/th][th]
B
[/th][th]
C
[/th][/tr]
[tr=bgcolor:#FFFFFF][td=bgcolor:#888888]
1
[/td][td][/td][td=bgcolor:#00B050]NAME=[/td][td][/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#888888]
2
[/td][td][/td][td=bgcolor:#00B050]PAR[/td][td][/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#888888]
3
[/td][td][/td][td][/td][td]Formula Result[/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#888888]
4
[/td][td]HOLDING ASOFDATE="03/31/2017" CUSIP="87612G101" MKT_VALUE="22998904.50" NAME="TARGA RESOURCES CORP" PAR="383955.00" PERCENT_PORT="1.5" PRICE="59.90"[/td][td=bgcolor:#FFFFFF]=MID(A4,SEARCH($B$1,A4)+(LEN($B$1)+1),SEARCH($B$2,A4)-SEARCH($B$1,A4)-(LEN($B$1)+3))[/td][td]TARGA RESOURCES CORP[/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#888888]
5
[/td][td]HOLDING ASOFDATE="03/31/2017" CUSIP="B0T9JZ902" MKT_VALUE="21217562.58" NAME="SPARK INFRASTRUCTURE GROUP" PAR="11733643.00" PERCENT_PORT="1.4" PRICE="2.37"[/td][td=bgcolor:#FFFFFF]=MID(A5,SEARCH($B$1,A5)+(LEN($B$1)+1),SEARCH($B$2,A5)-SEARCH($B$1,A5)-(LEN($B$1)+3))[/td][td]#VALUE![/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#888888]
6
[/td][td]HOLDING ASOFDATE="03/31/2017" CUSIP="B0T9JZ902" MKT_VALUE="21217562.58" NAME="PARK INFRASTRUCTURE GROUP" PAR="11733643.00" PERCENT_PORT="1.4" PRICE="2.37"[/td][td=bgcolor:#FFFFFF]=MID(A6,SEARCH($B$1,A6)+(LEN($B$1)+1),SEARCH($B$2,A6)-SEARCH($B$1,A6)-(LEN($B$1)+3))[/td][td]#VALUE![/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#888888]
7
[/td][td]HOLDING ASOFDATE="03/31/2017" CUSIP="B0T9JZ902" MKT_VALUE="21217562.58" NAME="SARK INFRASTRUCTURE GROUP" PAR="11733643.00" PERCENT_PORT="1.4" PRICE="2.37"[/td][td=bgcolor:#FFFFFF]=MID(A7,SEARCH($B$1,A7)+(LEN($B$1)+1),SEARCH($B$2,A7)-SEARCH($B$1,A7)-(LEN($B$1)+3))[/td][td]SARK INFRASTRUCTURE GROUP[/td][/tr]
[/table]
[Table="width:, class:grid"][tr][td]Sheet: Sheet1[/td][/tr][/table]
 
Last edited:

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
It is because your formula is looking for "PAR", which in A5 and A6 there is "PAR" within the group/corp names... Change B2 to "PAR=" not just "PAR", that should correct it...

... remember, you are trying to find a unique identifier (or phrase) that every cell possesses... and in your scenario "PAR=" seems to to be something you could use for that. "PAR" is not unique because "PAR" can be within a group/corp name, but the odds of a group/corp name containing "PAR=" is incredibly unlikely.
 
Last edited:
Upvote 0
Solution
Try this formula instead:
=TRIM(LEFT(SUBSTITUTE(REPLACE(A1,1,FIND("NAME=",A1)+5,""),"""",REPT(" ",255)),255))
 
Upvote 0
Staring me right in the face...worked perfectly, thank you!
Scott: Your suggestion worked as well, I just need to spend some time to understand exactly how it works. Thanks.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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