+ Reply to Thread
Results 1 to 18 of 18

Getting weird values consistently formatted to proper number of characters -text & numbers

  1. #1
    Registered User
    Join Date
    07-25-2011
    Location
    California, USA
    MS-Off Ver
    Excel 2010 PC
    Posts
    19

    Unhappy Getting weird values consistently formatted to proper number of characters -text & numbers

    I have a bear of a spreadsheet I need to format and massage on a monthly basis and I feel like you experts would have a better idea of how best to go about this.

    I have a range of values that all need to ultimately end up looking like this: 060480 or 052447b <- 6 numeric values possibly followed a letter. Once I have them formatted, I need to sort them in order so that I can merge them into another spreadsheet.

    Here're some examples of my original output:

    1161
    1174
    1256_001
    1257_001
    1258_001
    1259_001
    12592_001
    12601_001
    12601a_001
    12601b_001
    12601c_001
    12601d_001
    12601e_001
    12603_001
    12603a_001
    12603b_001
    12649_001
    1265_001
    12683a_001
    12683a_002
    12683b_001
    12683b_002
    12683c_001
    12683c_002
    12683d_001
    12683d_002
    12683e_001
    12683e_002
    12703w_001
    12703ww_001
    12703x_001
    12703xx_001
    12703y_001
    12703yy_001
    12703z_001
    12703zz_001
    139
    1390
    13900_001
    1472
    1472_1

    As you can see, it's really inconsistent. Values with _002 are secondary and the rows will be deleted entirely. Starting out, I could strip out everything after the underscores, but then I lose the information that lets me know that it's the secondary value (which I can get rid of later, but there's another column dependent upon my knowing that information).

    The way I've been doing it has been to do a lot of manual sorting, but I have about 11,000 rows to do

    So to sum up, the first part of the value, the numbers, needs to be 6 numbers, with leading zeroes. Then the alphabetic information needs to be spared.

    I think I can start by deleting all of the _001s and _1s strings, then somehow deleting all rows that still retain an underscore (is there a formula or script for that?)

    Once that is done, how do I get the numeric part of the value to 6 numbers?

    I attached the spreadsheet I'm working on. Column B is dependent upon Column A, so all of my work is on Column B, and sorting, etc. is done on both columns together.

    Any advice is greatly appreciated!

    metadataformatting.xlsx

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Getting weird values consistently formatted to proper number of characters -text & num

    Did you upload the correct workbook? I see no values at all containing "_"?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    07-25-2011
    Location
    California, USA
    MS-Off Ver
    Excel 2010 PC
    Posts
    19

    Re: Getting weird values consistently formatted to proper number of characters -text & num

    Yep - I downloaded it again to check. If you scroll down to row 1421, they start to show up.

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Getting weird values consistently formatted to proper number of characters -text & num

    OK gotcha, I was looking in A, the lack of file extention threw me.

    If the format of B will always be like that if there is the "_???.tif" part, then this could form the 1st part of whatever we need to do with it...
    =--LEFT(B1421,FIND("_",B1421,1)-IF(ISNUMBER(--MID(B1421,FIND("_",B1421,1)-1,1)),1,2))

    Give it a try (I started in C1421), and see if this will get us started inteh right direction?

  5. #5
    Registered User
    Join Date
    07-25-2011
    Location
    California, USA
    MS-Off Ver
    Excel 2010 PC
    Posts
    19

    Re: Getting weird values consistently formatted to proper number of characters -text & num

    Thanks FDibbins. Unfortunately, it bodges out the alphanumerics in some of the values.

    Here's what I've come up with so far (later to be made into one giant, nasty macro...):
    • Strip .TIF from Filenames
    • Strip _001 and _1 from Filenames
    • Apply formula =IF(FIND("_",B2),"TRUE","FALSE") to Column C
    • Copy and paste values for Column C
    • Delete all rows with TRUE in it
    • Move S (slides) to Sheet 2 (deal with those later)
    • Move tripartate values to Sheet 3 (deal with those later)
    • Strip out alphabetics and -* and paste to Column C
    ^^^^ That last bit is where I'm currently stuck, because it can be either one or two values from the right, depending on if it's "a", "AA", "b", etc. Any ideas on this part of it?

    If I can get the alphabetics out, sort on column B, then move column C back into column B, then that should be it (for the first stage of this project, anyway).

    Coincidentally, I got an email this morning from my client telling me how they're helpfully going to streamline their process and are coming up with a new numbering system. To which all I can think is that I now have a new number format to deal with. Ahhhhhhhhh!!!!!!!!!!!!

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Getting weird values consistently formatted to proper number of characters -text & num

    Thanks FDibbins. Unfortunately, it bodges out the alphanumerics in some of the values.
    Can you show me where this happens?

    Also, I didnt say this was te answer, I said this could form the start of the answer

    Form the small sample I tested it on, it seems to work fine?
    A
    B
    C
    D
    1421
    19412176 12679a_001.tif
    12679
    1422
    19412226 12679b_001.tif
    12679
    1423
    19412276 12681_001.tif
    12681
    1424
    19412326 12683a_001.tif
    12683
    1425
    19412376 12683a_002.tif
    12683
    1426
    19412426 12683b_001.tif
    12683
    1427
    19412476 12683b_002.tif
    12683
    1428
    19412526 12683c_001.tif
    12683
    1429
    19412576 12683c_002.tif
    12683
    1430
    19412626 12683d_001.tif
    12683
    1431
    19412676 12683d_002.tif
    12683
    1432
    19412726 12683e_001.tif
    12683
    1433
    19412776 12683e_002.tif
    12683
    1434
    19412826 12684a_001.tif
    12684
    1435
    19412876 12684a_002.tif
    12684
    1436
    19412927 12684b_001.tif
    12684
    1437
    19412977 12684b_002.tif
    12684
    1438
    19413027 12732a_001.tif
    12732
    1439
    19413071 12742a_001.tif
    12742
    1440
    19413115 12742b_001.tif
    12742
    1441
    19413159 12742c_001.tif
    12742
    1442
    19413202 12742d_001.tif
    12742
    1443
    19413246 12742e_001.tif
    12742
    1444
    19413290 12742f_001.tif
    12742
    1445
    19413334 12742g_001.tif
    12742
    1446
    19413378 12742h_001.tif
    12742
    1447
    19413422 12742i_001.tif
    12742
    1448
    19413466 12742j_001.tif
    12742
    1449
    19414180 2240I_2.tif
    2240
    1450
    19418836 12680_001.TIF
    12680


    row 1423 has no alpha, all the others do (even 1449)

  7. #7
    Registered User
    Join Date
    07-25-2011
    Location
    California, USA
    MS-Off Ver
    Excel 2010 PC
    Posts
    19

    Re: Getting weird values consistently formatted to proper number of characters -text & num

    yeah - I need to retain the alpha, so it would look like this:

    A B C D
    1421 19412176 12679a_001.tif 12679a
    1422 19412226 12679b_001.tif 12679b
    1423 19412276 12681_001.tif 12681
    1424 19412326 12683a_001.tif 12683a
    1425 19412376 12683a_002.tif (this row would be gone because it's a _002)
    etc.
    Last edited by Isara; 03-21-2014 at 08:25 PM. Reason: well that formatting was funky....

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Getting weird values consistently formatted to proper number of characters -text & num

    oops OK I thought you wanted to remove the alpha.

    Try this...
    =LEFT(B1421,FIND("_",B1421,1)-1)

    If you want the numerics shown as such...
    =IFERROR(--LEFT(B1421,FIND("_",B1421,1)-1),LEFT(B1421,FIND("_",B1421,1)-1))

  9. #9
    Registered User
    Join Date
    07-25-2011
    Location
    California, USA
    MS-Off Ver
    Excel 2010 PC
    Posts
    19

    Re: Getting weird values consistently formatted to proper number of characters -text & num

    Great. That works well to get rid of the trailing stuff. Now I'm trying to get it like this, because sorting won't work correctly on numerics vs. alphanumeric strings:

    From this:

    A B C
    27508025 003564b
    27508119 003565b
    28321497 003971b
    28321532 003971c
    30298558 01338A
    30298592 01338AA
    30298640 01338B
    30298674 01338BB

    To this:

    A B C
    27508025 003564 b
    27508119 003565 b
    28321497 003971 b
    28321532 003971 c
    30298558 01338 A
    30298592 01338 AA
    30298640 01338 B
    30298674 01338 BB

    And, of course, the number of numbers and the number of alphabetical characters is different, so I don't think I can do a simple RIGHT command. If I end up with something like this, then I can sort the whole batch on Column B, then concatenate C back onto the end of B values after sorting.

  10. #10
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Getting weird values consistently formatted to proper number of characters -text & num

    OK lets try this and see how far it gets you. Based on your sample file, use these, copied down...

    C2=IF(ISNUMBER(FIND("_",B2,1)),LEFT(B2,FIND("_",B2,1)-1),LEFT(B2,LEN(B2)-4))
    D2=SUMPRODUCT(--(B2>B$2:B$11400))+1
    Now this is where it all comes together, I used D and E, but you can put these where you want them
    E2=INDEX(sdmom032114,MATCH(ROW(A1),$D$2:$D$11400,0),MATCH(E$1,$A$1:$B$1,0))
    F2=INDEX(sdmom032114,MATCH(ROW(B1),$D$2:$D$11400,0),MATCH(F$1,$A$1:$B$1,0))

  11. #11
    Registered User
    Join Date
    07-25-2011
    Location
    California, USA
    MS-Off Ver
    Excel 2010 PC
    Posts
    19

    Re: Getting weird values consistently formatted to proper number of characters -text & num

    Ok, gave it a shot and I didn't get very far. Column C worked just fine, but then it looked like it kind of fell apart after that...?

    sdmomexcelformulas.gif

  12. #12
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Getting weird values consistently formatted to proper number of characters -text & num

    grrrr my bad, I forgot to tell you to copy your 2 headings to A1:B1 to E1:F1

    UMO ID FILE NAME

  13. #13
    Registered User
    Join Date
    07-25-2011
    Location
    California, USA
    MS-Off Ver
    Excel 2010 PC
    Posts
    19

    Re: Getting weird values consistently formatted to proper number of characters -text & num

    Hmm. Still getting the same #N/A result.

    sdmomexcelformulas2.gif

  14. #14
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Getting weird values consistently formatted to proper number of characters -text & num

    Did you copy the formulas all the way down?

    see the attached
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    07-25-2011
    Location
    California, USA
    MS-Off Ver
    Excel 2010 PC
    Posts
    19

    Re: Getting weird values consistently formatted to proper number of characters -text & num

    ah, no, I hadn't. My bad!

    So I'm not entirely sure what I'm looking at - what is column D? I think I'm still stuck in a place where I can't sort on the numeric part of the values (and ignoring the letters)

  16. #16
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Getting weird values consistently formatted to proper number of characters -text & num

    We have been on this for a few days now, and I have lost track of what we were doing

    I have tried another approach, based on your last post. Delete all formulas but the 4 in 2 (C2:F2...keep these in case we need to go back to them)

    Now, in G2, copied down, use this. Because you have such a large amount of data, it will probably slow things down a lot, but once you have the answers, you can copy/paste values (again, leave the 1st 1 so you can use it later)...
    =LOOKUP(99^99,--("0"&MID(B2,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},B2&"0123456789")),ROW($1:$11400)))) Courtesy of:*Ron Coderre

    Copy/past values

    Now copy these and paste down...
    H2=INDEX($A$2:$A$11400,MATCH(SMALL($G$2:$G$11400,ROW(A1)),$G$2:$G$11400,0))
    I2=INDEX($B$2:$B$11400,MATCH(SMALL($G$2:$G$11400,ROW(A1)),$G$2:$G$11400,0))

    This *should* list all your files in numerical order

  17. #17
    Registered User
    Join Date
    07-25-2011
    Location
    California, USA
    MS-Off Ver
    Excel 2010 PC
    Posts
    19

    Re: Getting weird values consistently formatted to proper number of characters -text & num

    Oh, that's brilliant! So very, very close. There are a bunch of duplicate values that appear in H and I, which appear to be the formula replacing some (but not instances) of the letter with "a". For example, at B3643 and B3644 the values are 25523a_001.TIF and 25523b_001.TIF. In I8023 and I8024, the values are both 25523a_001.TIF.

    I've attached the results with the duplicates highlighted.

    (for the record, my brand new gaming desktop computer is now getting cranky at all of these files I have open. Who knew it would be Excel that brought it to its knees?)

    metadataformatting2.xlsx

  18. #18
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Getting weird values consistently formatted to proper number of characters -text & num

    hmm yes I see what you mean. Lets try this instead. Insert a new column after G, and in (new) H2, copy this down...
    =G2+COUNTIF($G$2:G2,G2)/1000

    Then adjust the other 2 formulas to reference H instead of G...
    I2=INDEX($A$2:$A$11400,MATCH(SMALL($H$2:$H$11400,ROW(A1)),$H$2:$H$11400,0))
    J2=INDEX($B$2:$B$11400,MATCH(SMALL($H$2:$H$11400,ROW(A1)),$H$2:$H$11400,0))

+ 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. Convert Text-Formatted Numbers To Number Format
    By accell in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-12-2014, 12:58 PM
  2. [SOLVED] Convert all numbers stored as text or custom formatted to numbers &no decimals - 40 sheets
    By synses in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-19-2013, 01:46 AM
  3. Extracting numbers and text from inconsistent text/number formatted string
    By Brandivil in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-25-2013, 01:46 PM
  4. Replies: 16
    Last Post: 08-21-2011, 11:08 PM
  5. Insert Characters in cell with formatted text
    By MichaB in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-17-2006, 08:25 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