+ Reply to Thread
Results 1 to 20 of 20

Extract Digits with relevant characters

  1. #1
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Extract Digits with relevant characters

    Hi,

    I have a list (col. Q) of items incl. other parameters - such as:

    18 Kg Cement
    7/32" Screw
    Wooden board board 4.5"/5.5"
    12.34 meters wire

    In general I'm looking for a Sheet Formula (no UDF - which I already wrote) in order to extract the Numeric Digits(0,1,2,3,4,5,6,7,8,9) AND all relevant characters.

    Requested returns:
    18
    7/32"
    45"/5.5"
    12.34

    In fact I would like to extract CHAR(35) up to CHAR(64)

    What will be the formula to achieve that ?

    Thanks, Elm
    Last edited by ElmerS; 03-03-2010 at 04:31 AM.

  2. #2
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Extract Digits with relevant characters

    but inch is CHAR(34) ?

    Why inches and not meters?
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  3. #3
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Re: Extract Digits with relevant characters

    Sorry for the TYPO

    Results should read:

    18
    7/32
    4.5/5.5
    12.34

    Thanks, Elm

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Extract Digits with relevant characters

    use your udf! if it works.
    seems a waste of effort trying to parse those examples.
    is that the only way things are presented?
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Re: Extract Digits with relevant characters

    Thanks.

    All digits can be mixed with/among CHAR(34) ---> CHAR(47) and CHAR(58) ---> CHAR(64)

    No guarantee how many repetitions there will be within one string.

    It could be also: Block 4.5/5.5/6.5 (requested result: 4.5/5.5/6.5)

    As I have the UDF that handles it - I still would like to learn if and how this can be achieved with a "pure" Worksheet formula.

    If you have something in mind and don't care to spend a few moments - I will appreciate.

    Elm

  6. #6
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Extract Digits with relevant characters

    Fully agree with Martin, UDF is most readable
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  7. #7
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Extract Digits with relevant characters

    how about a few helper columns
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Re: Extract Digits with relevant characters

    Quote Originally Posted by rwgrietveld View Post
    Fully agree with Martin, UDF is most readable
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

    As I don't like codes to be "too long" - I will stick to my UDF as long as I won't get the requested formula.

    Please Login or Register  to view this content.
    Elm

  9. #9
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Re: Extract Digits with relevant characters

    Thanks, Martin,

    With all due respect, especially not knowing the serious level (from 1-10) of your suggestion, therefor with you permission I will not comment about your "Helper-Columns" suggestion.

    Elm
    Last edited by ElmerS; 03-01-2010 at 09:16 AM.

  10. #10
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Extract Digits with relevant characters

    well it just demonstrates the levels of nesting you'd need,thats why a function isn't probably the best idea

  11. #11
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Extract Digits with relevant characters

    Quote Originally Posted by Elm
    With all due respect, especially not knowing the serious level (from 1-10) of your suggestion, therefor with you permission I will not comment about your "Helper-Columns" suggestion
    Quote Originally Posted by Elm
    As I don't like codes to be "too long" - I will stick to my UDF as long as I won't get the requested formula.
    Sounds like you are dissapointed, but I think Martin just showed you that it will be a "unreadable" formula. The UDF you wrote is straight forward and easy to read. Much better. I would go for that.

  12. #12
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Re: Extract Digits with relevant characters

    This is as closest as I could get with a "2007" ws formula.

    It could probably be more sophisticated.

    Elm
    Attached Images Attached Images
    Last edited by ElmerS; 03-01-2010 at 03:41 PM.

  13. #13
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Extract Digits with relevant characters

    fair point
    but it falls down if text after number string
    say
    Wooden board 4.5/5.5 black
    =SUBSTITUTE(MID(A1,MIN(FIND({1,2,3,4,5,6,7,8,9,0},A1&1234567890)),256),CHAR(34),"")
    returns
    4.5/5.5 black
    so you'd have to nest it again possibly several times

  14. #14
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Re: Extract Digits with relevant characters

    Probably, but I assume the nested levels won't be as many as Martins amount of columns.
    OR:
    I will force the user to type: Black Wooden board 4.5/5.5

    Thanks, Elm

  15. #15
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Extract Digits with relevant characters

    Elm,

    can't let it go. This is the best I can do

    HTML Code: 
    where MyRng is a named range:
    HTML Code: 
    Hope you like it (I like your UDF better)

    As you are not a NOOB, you've probably seen its a CSE function (Array function)
    Last edited by rwgrietveld; 03-01-2010 at 05:43 PM.

  16. #16
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Re: Extract Digits with relevant characters

    Thank you very much.

    I am glad you took it as a challenge and the result looks promising.

    Elm

  17. #17
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Re: Extract Digits with relevant characters

    Hi, Ricardo,
    5 more minutes of your precious time, to look at the attached WB, please.

    I have decided to reduce the alphabetic characters to only '/' and '.' - so, I have declared an additional named range: MyRng2 and changed your formula to meet the new reduced request.

    Cells B10:B12 return the expected values however, cells B13:B16 does not.

    What did I do wrong ?

    btw: I expected your formula to return what I hand-typed in C7 and not what it returns in B7.

    Thanks again for all your efforts,
    Elm
    Attached Files Attached Files

  18. #18
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Extract Digits with relevant characters

    It's simple.

    You have adjusted the range from A1:A30 to A1:A14.

    The 30 is arbitrary (can be 100) but it should at least be longer the the max # of characters in the string. 14 does not comply.

    Solution.

    Extend range 14 to > 30 for both the formula as well as the named range.

  19. #19
    Forum Contributor
    Join Date
    11-28-2008
    Location
    Reykjavík, Iceland
    MS-Off Ver
    Any of: 2003 & 2007
    Posts
    412

    Re: Extract Digits with relevant characters

    Wooowww, we are almost there.

    It works as expected on A10:A15 - however, for A16 it returns: 4.5*5.5*6.5 although the character '*' (Code 42) is not within: (MyRng2>45)*(MyRng2<58)

    For A16 I expect: 4.55.56.5

    Hope you can help me with that, probably, last issue.

    Thanks, Elm

  20. #20
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Extract Digits with relevant characters

    My formula looks at the first and the last numerical and takes ALL numericals in between.

    55 ALL 55 will not change either
    only 55 ALL and ALL 55

    ... and this threa is closed for a while. Open a new one. so others will be invited to contribute (or UN-SOLVE this thread)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1