• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to extract numbers alphanumeric text

Lingks

New Member
How to extract numbers like 123456-A only.

from …. to ….

775506-V 775506
206981-D 206981
545077-A 545077
372194-M 372194
971720-K 971720
81500-D 81500
1089523-K 1089523
648330-T 648330
794417-M 794417
950894-T 950894
21731-K 21731
1129538-D 1129538
409627-D 409627
LL10413 10413
456668-U 456668
 

Attachments

  • Book1.xlsx
    8.3 KB · Views: 10
Hi, while i am doing the testing just now. i add on one scenario like 0123456-a the formula does not show zero in front, how can i solve this?

The outcome should be 0123456.

upload_2017-3-15_10-0-27.png
 
Hi, while i am doing the testing just now. i add on one scenario like 0123456-a the formula does not show zero in front, how can i solve this? The outcome should be 0123456.
Hi,

1] In A3, array formula (confirm pressing CTRL+SHIFT+ENTER 3 keystrokes together) copy down :

=MID(A3,MIN(FIND(ROW($1:$10)-1,A3&1/19)),COUNT(-MID(A3,ROW($1:$99),1)))

2] See attachment.

Regards
Bosco
 

Attachments

  • ExtractDigit.xlsx
    9.7 KB · Views: 6
Just for the kicks, following should work (non-CSE). Bosco's formula is better from maintainability point of view.
=MID(A3,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A3&"0123456789",1)),(LOOKUP(2,1/ISNUMBER(--MID(A3,ROW($A$1:INDEX($A:$A,LEN(A3))),1)),ROW($A$1:INDEX($A:$A,LEN(A3))))+1)-MIN(FIND({0,1,2,3,4,5,6,7,8,9},A3&"0123456789",1)))
 
Another non-CSE formula in similar concept of Shrivallabha's, just using MATCH instead of LOOKUP.

=MID(A3,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A3&1/19)),MATCH(1,INDEX(-MID(A3,ROW($1:$99),1),0))-MIN(FIND({0,1,2,3,4,5,6,7,8,9},A3&1/19))+1)

Regards
Bosco
 
A] CSE means CTRL+SHIFT+ENTER which is required for committing Array formulas. Array formulas are powerful way of achieving / working out results in much the similar ways as non-CSE formulas do.

In normal scenario, an array formula may not be a big overhead but the crux is to remember to commit formula by using CSE strokes simultaneously. If you enter formula normally it will return some error or incorrect results or a rare correct result for a case which will become incorrect as soon as parameters change etc. So precisely from that perspective, a normal user may get wrong results due to no knowledge of CSE entry.

B] The formula posted by Bosco though CSE, is simpler to read and interpret (if compared with the formula I've posted later) and therefore easier to implement in other situations e.g. changes in layouts etc. So that it is better from maintainability viewpoint.

Hope this explains. With this in mind, you should be able to decide which formula will suit you better!
 
Back
Top