On a take off of Formula Forensic No. 021 – Find the 4th Slash !
I am trying to break a part number out of a text string. so I convert the string to a single charachter array and check the code of each charachter to see if it is number greater than 47 AND less than 58. This would tell that charachter is a number. I can find >47 or <58 easy enough. The trouble is to find >47AND<58 in a simple formula.
Here is a sample string:
21001253 CONN,RECEPTACLE,2 PIN,
This particular string has a space after the part number and it would be easy to just find the first " " . However not all data is clean there is not always a space after the last digit in the part number.
Here is my solution so far:
LEFT(V4,SUM((CODE(MID(SUBSTITUTE(V4," ",CHAR(135)),ROW(INDIRECT("1:"&LEN(V4))),1))<58)+0))
The problem is this formula will pick up other punctuation marks to count the length of the result string and cause an inaccurate result. eg.
21001253 CON
Instead of:
21001253
Because CODE(",") =44 making the Num_Chars in the LEFT func =12 instead of 10. Doh!!! I just realised there is an extra digit in the string. that will also return inaccurate results.
Anyway I have found my own solution unique to my data set (max part number can only be 13 charachters.... Probably. So instead of checking the entire string I will only check the first 13 or 14 charachters) but I would like to see others ideas if you care to try. I would still like to know how to check if each item in an array is between a range. For example: How many charachters in a text string are numbers 0-9?
Thanks
WCoaster
I am trying to break a part number out of a text string. so I convert the string to a single charachter array and check the code of each charachter to see if it is number greater than 47 AND less than 58. This would tell that charachter is a number. I can find >47 or <58 easy enough. The trouble is to find >47AND<58 in a simple formula.
Here is a sample string:
21001253 CONN,RECEPTACLE,2 PIN,
This particular string has a space after the part number and it would be easy to just find the first " " . However not all data is clean there is not always a space after the last digit in the part number.
Here is my solution so far:
LEFT(V4,SUM((CODE(MID(SUBSTITUTE(V4," ",CHAR(135)),ROW(INDIRECT("1:"&LEN(V4))),1))<58)+0))
The problem is this formula will pick up other punctuation marks to count the length of the result string and cause an inaccurate result. eg.
21001253 CON
Instead of:
21001253
Because CODE(",") =44 making the Num_Chars in the LEFT func =12 instead of 10. Doh!!! I just realised there is an extra digit in the string. that will also return inaccurate results.
Anyway I have found my own solution unique to my data set (max part number can only be 13 charachters.... Probably. So instead of checking the entire string I will only check the first 13 or 14 charachters) but I would like to see others ideas if you care to try. I would still like to know how to check if each item in an array is between a range. For example: How many charachters in a text string are numbers 0-9?
Thanks
WCoaster