Parsing Text Fields

myers_co

New Member
Joined
Mar 23, 2015
Messages
6
I have a column containing mixed data that I need to parse and extract a particular portion from but I've run out of brain power in figuring this one out. The data in the column is a combination of string codes and number codes that are joined by a varying number of spaces (no apparent rhyme or reason) and occasionally other symbols (like ~!@#$%^&*-_=+). The following list shows SOME of the possibilities of combinations that this column contains:

TRISTAR(15 spaces)M4 04333-0032
WIND ONE(11 spaces)K5
EXTRENDO(13 spaces)D1 92366
WILK17(17 spaces)K7 140 816
A-723(2 spaces)121-701
SAW SCAW 2222

It is a horrible mess! What I need to do is find a way to submit a pattern to a function and have the function return a zero (not found) or a numeric value (the position in the string) where the pattern is located. The pattern needs to allow for spaces, characters, digits and symbols (in fixed and variable quantities).

Examples:
=PARSE(A1, "[D5]-[D4]") should result in 26 for the first data example but return 0 for all others. The "[D5]-[D4]" pattern would describe 5 digits connected with a dash connected to 4 digits.

=PARSE(A1,"[SX][CD]") should result in 23 for the first example, 20 for the second, 22 for the third, 24 for the fourth, 0 for the fifth and 0 for the sixth. The "[SX][CD]" pattern would describe a variable number of spaces immediately followed by a character and digit combination.
 
Last edited:
OK, fair enough but any user of the function is ..
a) going to have to know that it uses the Like operator, and
b) have a very good understanding of how the Like operator, and the overall functions works
.. if they are to devise any successful pattern for it.
Well, yes, that is true, but no more so than for the function you posted in Message #4. My modification to your function will simply allow the user to do exactly whatever you intended in your function, but with the ability to use wildcards (? for single character, * for zero or more characters).
 
Upvote 0

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).
Upvote 0

Forum statistics

Threads
1,215,882
Messages
6,127,535
Members
449,385
Latest member
KMGLarson

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