Excluding text before character

shedboyxx

New Member
Joined
Apr 13, 2011
Messages
11
Hi folks,

I have a feeling this is simple but I’m coming up blank. I have a field that contains text separated by backslashes. The number of backslashes are always the same

example 1
info1\info2\information3\info4\info5\here's what I want to exclude

I’m looking for a calculation that gives me all of the text that happens before the 5<sup>th</sup> occurrence of a backslash.

example 2
info1\info2\information3\info4\info5

I tried using Find, Right and Left in different combinations but failed

Let me know if you have something that will work.

TIA

Jim
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hi folks,

I have a feeling this is simple but I’m coming up blank. I have a field that contains text separated by backslashes. The number of backslashes are always the same

example 1
info1\info2\information3\info4\info5\here's what I want to exclude

I’m looking for a calculation that gives me all of the text that happens before the 5<SUP>th</SUP> occurrence of a backslash.

example 2
info1\info2\information3\info4\info5

I tried using Find, Right and Left in different combinations but failed

Let me know if you have something that will work.

TIA

Jim
Try this...

=LEFT(A2,FIND("^",SUBSTITUTE(A2,"\","^",5))-1)
 
Upvote 0
Thanks for both versions!

Unfortunately I must be doing something wrong as I'm getting the dreaded #VALUE result. I copied and pasted as is and used the example data both the same reference cell (A2) and another cell (A9), changing the formula on the latter.

What could I be doing wrong? The cells are formatted as General

TIA
 
Upvote 0
Thanks for both versions!

Unfortunately I must be doing something wrong as I'm getting the dreaded #VALUE result. I copied and pasted as is and used the example data both the same reference cell (A2) and another cell (A9), changing the formula on the latter.

What could I be doing wrong? The cells are formatted as General

TIA
If there aren't at least 5 of the slash characters you'll get a #VALUE! error. But you did say:

The number of backslashes are always the same

Can you post an example of the cell entry and the EXACT formula you tried that gives the error?
 
Upvote 0
Hello everyone let me reintroduce myself...I'm the Town Dope...:laugh:
Ugh....

Target text was in B2 and I confused it with A2

It's working perfectly now. Thanks for your patience.

I did have one followup question since I've never used a caret (^) before in Excel. What does this character function as? If it's a very contextual answer then maybe just as it relates to this situation.

You guys are great!

Jim
 
Upvote 0
Hello everyone let me reintroduce myself...I'm the Town Dope...:laugh:
Ugh....

Target text was in B2 and I confused it with A2

It's working perfectly now. Thanks for your patience.

I did have one followup question since I've never used a caret (^) before in Excel. What does this character function as? If it's a very contextual answer then maybe just as it relates to this situation.

You guys are great!

Jim
The ^ symbol is typically used in math to mean "to the power of".

For example:

10^3 means 10 to the 3rd power or 10 * 10 * 10 = 1000

We can express that in a formula:

=10^3
 
Upvote 0
In the context of the find & substitute formula, is "^" just being used as a character that's very unlikely to be somewhere else in the string?
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,855
Members
452,948
Latest member
UsmanAli786

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