MID Function to find a string within brackets

Peteor

Board Regular
Joined
Mar 16, 2018
Messages
136
Hello I am using the following:

=MID(B5,SEARCH("[",B5)+1,SEARCH("]",B5)-SEARCH("[",B5)-1)+0

Where cell B5 has the following contents:
=IF(B6="","rdhgxfjhsftjhjh(Text to extract)hujkfjkdjsdt","")

and cell B6 is blank.

I am receiving a #Value error, and am unsure why. My cells are formatted to Category "General".

I am trying to look at a specific cell (in excel, not VBA) where my "Text to extract" will be part of a formula and within brackets. Does anyone have any ideas?
 

Some videos you may like

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

sandy666

Banned - Rules violations
Joined
Oct 24, 2015
Messages
7,499
you defined [ but string doesn't contain this so... #VALUE !
 
Last edited:

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
52,727
Office Version
  1. 365
Platform
  1. Windows
Couple of things
1) your text string has brackets (), whilst your formula is looking for braces [].
2) You are trying to add 0 to a text string, which cannot work.
 

Peteor

Board Regular
Joined
Mar 16, 2018
Messages
136
I see. Part of this was my mistake. I edited the formula I listed here to have the braces, and forget to edit the contents of B5. Both B5 and my formula have Braces on the Excel file, and are still returning the #Value error.

Fluff - Thank you! I removed to + 0 and it extracted my string. Problem solved! Thank you everyone.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
52,727
Office Version
  1. 365
Platform
  1. Windows
Glad we could help & thanks for the feedback
 

Watch MrExcel Video

Forum statistics

Threads
1,122,162
Messages
5,594,609
Members
413,917
Latest member
devansh02

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