+ Reply to Thread
Results 1 to 15 of 15

Strip multi character string into numbers and paste to respective columns

  1. #1
    Registered User
    Join Date
    12-14-2014
    Location
    UK
    MS-Off Ver
    Pro Plus 2010
    Posts
    5

    Strip multi character string into numbers and paste to respective columns

    Hi,

    I have a column with various strings in it representing time periods:

    1w10h
    19h36m
    15h49m
    22h36m
    2mo2w
    5mo1w
    6d13h

    where:

    y = years
    mo =months
    w = weeks
    d = days
    h = hours
    m = minutes

    How would I go about stripping each string into columns such that it shows the following:




    STRING YEARS MONTHS WEEKS DAYS HOURS MINUTES
    1w10h 0 0 1 0 10 0
    19h36m 0 0 0 0 19 36
    15h49m 0 0 0 0 15 49
    22h36m 0 0 0 0 22 36
    2mo2w 0 2 2 0 0 0
    5mo1w 0 5 1 0 0 0
    6d13h 0 0 6 13 0 0


    Any help appreciated.

    Kind regards

    Shaolin666
    Last edited by Shaolin666; 12-14-2014 at 12:20 PM.

  2. #2
    Registered User
    Join Date
    05-10-2013
    Location
    Pomáz, Hungary
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Strip multi character string into numbers and paste to respective columns

    Enter the bold abbreviations into row 1, then enter into B2 (supposing minutes/m/ -if exists – is always at the end):

    =IFERROR(LOOKUP(1000,--MID($A2,SEARCH(B$1,$A2)-{1,2,3},{1,2,3})),0)

    Copy down and across as needed.

  3. #3
    Registered User
    Join Date
    05-10-2013
    Location
    Pomáz, Hungary
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Strip multi character string into numbers and paste to respective columns

    From B1 to G1, enter: | Y | Mo | W |D |H | Min |
    Last edited by István Hirsch; 12-14-2014 at 11:21 AM.

  4. #4
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Strip multi character string into numbers and paste to respective columns

    smth like that
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    05-10-2013
    Location
    Pomáz, Hungary
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Strip multi character string into numbers and paste to respective columns

    Quote Originally Posted by tim201110 View Post
    smth like that
    I do not get correct result if both "mo" and "m" also exist in the string. I guess m for minutes is found in mo for months, this causes the problem.

  6. #6
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Strip multi character string into numbers and paste to respective columns

    yes, maybe Shaolin666 will do smth with it

  7. #7
    Registered User
    Join Date
    12-14-2014
    Location
    UK
    MS-Off Ver
    Pro Plus 2010
    Posts
    5

    Re: Strip multi character string into numbers and paste to respective columns

    Thank you very much for your help and suggestions. it doesn't matter that "mo" and "m" together give an error since they never appear together in the same string.

    thank you very much for all of your help. i used your examples and have it working as desired

    kind regards

    Shaolin666

  8. #8
    Registered User
    Join Date
    05-10-2013
    Location
    Pomáz, Hungary
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Strip multi character string into numbers and paste to respective columns

    Thank you very much for your help and suggestions. it doesn't matter that "mo" and "m" together give an error since they never appear together in the same string.

    thank you very much for all of your help. i used your examples and have it working as desired

    kind regards

    Shaolin666
    Edit: my formula (post #2) correctly:

    =IFERROR(LOOKUP(1000,--MID($A8,SEARCH(B$1,$A8&"in")-{1,2,3},{1,2,3})),0)


    I must be doing something wrong, but for me the formula in post #4 does not give the needed results for example, for strings like 10w2h, 19h3m, 2h3m, 2mo1w, 9d6h etc. Do you get the correct result with these examples?

  9. #9
    Banned User!
    Join Date
    10-29-2012
    Location
    Europe
    MS-Off Ver
    2013, 2016
    Posts
    318

    Re: Strip multi character string into numbers and paste to respective columns

    it doesn't matter that "mo" and "m" together give an error since they never appear together in the same string.
    in this case:
    2mo2w 0 2 0 0 0 2 with month and weeks, tim201110 formula is wrong.

  10. #10
    Registered User
    Join Date
    12-14-2014
    Location
    UK
    MS-Off Ver
    Pro Plus 2010
    Posts
    5

    Re: Strip multi character string into numbers and paste to respective columns

    Thank you István Hirsch, you are correct!!

    In my hurry to leave the house yesterday it looked correct, but your correction is nearly 100% correct.

    Using your amended formula:

    =IFERROR(LOOKUP(1000,--MID($A8,SEARCH(B$1,$A8&"in")-{1,2,3},{1,2,3})),0)

    There is a small error with "mo" entries

    i.e.

    2mo2w & 5mo1w gives:


    STRING YEARS MONTHS WEEKS DAYS HOURS MINUTES
    2mo2w 0 2 2 0 0 2
    5mo1w 0 5 1 0 0 5



    0 2 2 0 0 2
    0 5 1 0 0 5

    This forumla is adding minutes when there are none. Taking the same value for months
    Last edited by Shaolin666; 12-15-2014 at 12:43 PM.

  11. #11
    Banned User!
    Join Date
    10-29-2012
    Location
    Europe
    MS-Off Ver
    2013, 2016
    Posts
    318

    Re: Strip multi character string into numbers and paste to respective columns

    Using István Hirsch formula:

    =IFERROR(LOOKUP(1000,--MID($A2,SEARCH(B$1,$A2&"in")-{1,2,3},{1,2,3})),0)
    you get:

    STRING Y Mo W D H Min
    1w10h 0 0 1 0 10 0
    19h36m 0 0 0 0 19 36
    15h49m 0 0 0 0 15 49
    22h36m 0 0 0 0 22 36
    2mo2w 0 2 2 0 0 0
    5mo1w 0 5 1 0 0 0
    6d13h 0 0 0 6 13 0

    and this is correct. No minutes as you specify. Maybe you dont change formula for each places...
    Last edited by Indi_Ra; 12-15-2014 at 02:17 PM.

  12. #12
    Registered User
    Join Date
    05-10-2013
    Location
    Pomáz, Hungary
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Strip multi character string into numbers and paste to respective columns

    Please use the abbreviations suggested and check if the value of cell G1 is "Min" and not only "M":


    My version.jpg

  13. #13
    Registered User
    Join Date
    12-14-2014
    Location
    UK
    MS-Off Ver
    Pro Plus 2010
    Posts
    5

    Re: Strip multi character string into numbers and paste to respective columns

    Quote Originally Posted by István Hirsch View Post
    Please use the abbreviations suggested and check if the value of cell G1 is "Min" and not only "M":


    Attachment 364963
    Excellent, Thank you!

    I now have it working perfectly thanks to your advice of using the abbreviations as suggested using "Min" instead of "m".

    Sincerely, thank you very much!! I appreciate it

    kindest regards

    Shaolin666

  14. #14
    Registered User
    Join Date
    05-10-2013
    Location
    Pomáz, Hungary
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: Strip multi character string into numbers and paste to respective columns

    You are welcome, thanks for the feedback.

  15. #15
    Registered User
    Join Date
    12-14-2014
    Location
    UK
    MS-Off Ver
    Pro Plus 2010
    Posts
    5

    Re: Strip multi character string into numbers and paste to respective columns

    You are welcome, thanks for the feedback.
    Thank you once again....I added to your reputation for your help with my problem. I also added to Indi_Ra's rep.

    You are an excel star
    Last edited by Shaolin666; 12-15-2014 at 03:22 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro to strip out items in text file and paste into columns
    By reesjordan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-16-2014, 01:16 PM
  2. [SOLVED] Splitting numbers and text to their respective columns
    By JEAN1972 in forum Excel General
    Replies: 7
    Last Post: 07-31-2014, 06:48 AM
  3. [SOLVED] Sum numbers left of a character from within a string
    By BarryTSL in forum Excel General
    Replies: 14
    Last Post: 04-17-2012, 01:11 PM
  4. [SOLVED] Text to Columns with multi-character delimiters
    By Dave B in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2005, 01:30 PM
  5. Strip text before character
    By bell23 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-29-2005, 06:05 AM

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