Extract A String Between Two Characters

theaudioguy

New Member
Joined
Jan 27, 2010
Messages
27
I'm stuck. I need a formula to extract data from between two characters.

For Example, In A1 I have this: COMP_PROG_v1_ABCD_01

I want to extract the value between the 3rd and 4th "_"'s. The number of "_"'s will be consistent but not the # of characters between them. My brain is tired of thinking. Thanks.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Also if somebody else is interested by the same problem, it is possible to use Rick's formula slightly altered to make it work with columns like that

Description 1 Description 2 Description 3 Description 4 Description 501-30-2017 10:44:14.2313 TYPE_INFORMATION MessageInformation.SomeInformation Description of the record : MSRV A221 More description in text

Original text in A1, copy this in A2 and drop on the right.
=TRIM(MID(SUBSTITUTE("|"&$A1,"|",REPT(" ",LEN($A1))),COLUMNS($A:A)*LEN($A1),LEN($A1)))
 
Upvote 0
Hello guys,
can anyone help with slightly different formula? Text is all-in-one, and needs to be separated in 5 columns according to header. There are 6, 5, 9 and 11 spaces between each text field. Thank you for help.

Date Time Level Source Event
7.2.2017 3:24:45 Warning KEPServerEX\Runtime Device 'A_VS20_St050.FX3U' has been auto-demoted.
7.2.2017 3:24:45 Warning KEPServerEX\Runtime Device 'B_St020.FX3U' has been auto-demoted.
7.2.2017 4:14:21 Information KEPServerEX\Runtime Kepware Communications Server 5.4
7.2.2017 4:14:23 Information Mitsubishi Ethernet Mitsubishi Ethernet Device Driver V5.4.135.0


-- removed inline image ---
 
Upvote 0
Hello guys,
can anyone help with slightly different formula? Text is all-in-one, and needs to be separated in 5 columns according to header. There are 6, 5, 9 and 11 spaces between each text field. Thank you for help.

Date Time Level Source Event
7.2.2017 3:24:45 Warning KEPServerEX\Runtime Device 'A_VS20_St050.FX3U' has been auto-demoted.
7.2.2017 3:24:45 Warning KEPServerEX\Runtime Device 'B_St020.FX3U' has been auto-demoted.
7.2.2017 4:14:21 Information KEPServerEX\Runtime Kepware Communications Server 5.4
7.2.2017 4:14:23 Information Mitsubishi Ethernet Mitsubishi Ethernet Device Driver V5.4.135.0



-- removed inline image ---

Please mark where each substring begins.
 
Upvote 0
There are 6, 5, 9 and 11 spaces between each text field.
If that is so, does this work for you?
Formula is copied across.

Excel Workbook
ABCDEF
27.2.2017 3:24:45 Warning KEPServerEX\Runtime Device 'A_VS20_St050.FX3U' has been auto-demoted.*7.2.20173:24:45WarningKEPServerEX\RuntimeDevice 'A_VS20_St050.FX3U' has been auto-demoted.*
Extract Parts
 
Upvote 0
Peter_SSs,

it's almost perfect, but some logs are truncated.
this log
[TABLE="width: 812"]
<tbody>[TR]
[TD]7.2.2017 5:29:43 Information KEPServerEX\Configuration Opening project C:\Shared\OPC\Uni14_Daimler_2017_01_18_r00.opf[/TD]
[/TR]
</tbody>[/TABLE]


gives truncated last column:

Opening project C:\Shared\OPC\Uni14_Daimler_2017
 
Upvote 0
Extract Parts

*
A
B
CDEF
[TABLE="width: 812"]
<colgroup><col></colgroup><tbody>[TR]
[TD]7.2.2017 5:29:43 Information KEPServerEX\Configuration Opening project C:\Shared\OPC\Uni14_Daimler_2017_01_18_r00.opf

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:785px;"><col style="width:69px;"><col style="width:62px;"><col style="width:67px;"><col style="width:153px;"><col style="width:348px;"></colgroup><tbody>
[TD="bgcolor: #cacaca, align: center"]2[/TD]

</tbody>
[/TD]
[TD][TABLE="width: 67"]
<colgroup><col width="67"></colgroup><tbody>[TR]
[TD="width: 67"]7.2.2017[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD="align: right"][TABLE="width: 63"]
<colgroup><col width="63"></colgroup><tbody>[TR]
[TD="width: 63"]5:29:43[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 78"]
<colgroup><col width="78"></colgroup><tbody>[TR]
[TD="width: 78"]Information[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 179"]
<colgroup><col width="179"></colgroup><tbody>[TR]
[TD="width: 179"]KEPServerEX\Configuration[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 330"]
<colgroup><col width="330"></colgroup><tbody>[TR]
[TD="width: 330"]Opening project C:\Shared\OPC\Uni14_Daimler_2017
[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

Forum statistics

Threads
1,223,912
Messages
6,175,344
Members
452,638
Latest member
Oluwabukunmi

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