How to extract only numbers between two specific characters

analyst0503

New Member
Joined
Aug 5, 2021
Messages
15
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have a very specific example where I want to only extract numbers between specific characters and I can't find a formula to do this in bulk. Would be grateful for any help!

1628177606607.png

As you can see in the example above, I only want to keep a specific number. These are dates that will be 4 digits and therefore I would like to only extract those. They are separated by a pipe symbol. The pattern is always 4 digits between pipe symbols.

Thanks in advance!
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Can you provide more than one example so that we know if the locations vary in the PIPE. Perhaps a half dozen examples.
 
Upvote 0
How about
+Fluff 1.xlsm
ABCD
4
5Days|and|1989|this is an example|2001989
6Days|and|1989|this is an example|201019892010
7
List
Cell Formulas
RangeFormula
B5,B6:C6B5=TRANSPOSE(FILTERXML("<k><m>"&SUBSTITUTE(A5&"|","|","</m><m>")&"</m></k>","//m[string-length()=4and number()]"))
 
Upvote 0
How about
Code:
=TRIM(LEFT(SUBSTITUTE(MID(SUBSTITUTE($A2;"|";REPT(" ";LEN($A2)));LEN($A2)*2;LEN($A2));"|";REPT(" ";255));255))
 
Upvote 0
Thank you! I'll give them a try and report back on the progress.

I have another instance where the years are |1878-98|, is there a way to tackle this?
 
Upvote 0
Can you post some samples of your data & expected results.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
If your information that you wish to extract is located only in the third set of Pipe delimiters then Power Query will work regardless of the data in that third set.

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Extracted Text Between Delimiters" = Table.TransformColumns(Source, {{"Column1", each Text.BetweenDelimiters(_, "|", "|", 1, 0), type text}})
in
    #"Extracted Text Between Delimiters"
 
Upvote 0
Thank you all for your responses. Unfortunately, I'm unable to share the actual data but happy to add some screenshots.

Here are some of the samples of things that I'm trying to extract:

1628258399146.png


These are some patterns that I'm noticing. There will be multiple instances where there are numbers between pipes so these are some examples of the patterns.

Really appreciate everyone's help!
 
Upvote 0
How about
+Fluff 1.xlsm
ABCD
4
5Days|and|1989|this is an example|2001989
6Days|and|1989|this is an example|201019892010
7
List
Cell Formulas
RangeFormula
B5,B6:C6B5=TRANSPOSE(FILTERXML("<k><m>"&SUBSTITUTE(A5&"|","|","</m><m>")&"</m></k>","//m[string-length()=4and number()]"))
The Transpose formula looks great and I would love that kind of result but it doesn't work for me. Could it be that I'm doing something wrong? I tried doing both Enter and Ctrl+Shift+Enter but it only found two results.
 
Upvote 0
That data is nothing like your original request, so the formula I suggested will not work.
Further more there is no consistency in the data, so not sure how to do it.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,648
Messages
6,120,726
Members
448,987
Latest member
marion_davis

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