+ Reply to Thread
Results 1 to 10 of 10

Formula to Separate Values in Execel

  1. #1
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,000

    Formula to Separate Values in Execel

    I believe there is a way to get around this. Looking for a formula in excel to drop off values from the right when it sees the first dash (-). For example X9-8-06 = X9-8. Second example, V090-88 = V090. If the last values is 3 digits, the formula should not delete the values (stay the same). See sample list below:

    PHP Code: 
    Pages                    Magazine (desired outcome)
    Z25                      Z25
    X9
    -8-06                  X9-8
    V090
    -88                  V090
    ZZ
    -555                   ZZ-555
    Z555
    -55                  Z555
    ZZZZ                     ZZZZ
    CX78M                    CX78M
    Y67                      Y67
    K022                     K022
    LL78                     LL78 
    Thanks.
    Last edited by bjnockle; 02-26-2014 at 10:10 PM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: Formula to Separate Values in Execel

    Why does V090-88 become V090 but ZZ-555 stays ZZ-555 and ZZ-55 stays ZZ-55. What is your logic?
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Formula to Separate Values in Execel

    I'd use a small UDF:
    Please Login or Register  to view this content.
    Use as:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  4. #4
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,000

    Re: Formula to Separate Values in Execel

    alansidman: ZZ-55 was a typo...I meant to type ZZ-555 = ZZ-555. If the last values is 3 digits, the value should remain the same.

    Thanks

  5. #5
    Forum Contributor
    Join Date
    02-06-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    1,000

    Re: Formula to Separate Values in Execel

    OllyXLS: Thanks for the code. Is there a formula that can accomplish the same goal with VBA?

  6. #6
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Formula to Separate Values in Execel

    I wish you wouldn't edit your initial post / requirement after I have posted a solution - it looks like I ignored the "last 3 digits as number" requirement, when it wasn't actually there. To accommodate that additional requirement, use:
    Please Login or Register  to view this content.
    I presume your last post means you would like a formula solution WITHOUT using VBA? There probably is. I would use a UDF, though.
    Last edited by Olly; 02-26-2014 at 10:32 PM. Reason: typos

  7. #7
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Formula to Separate Values in Execel

    Maybe this

    =IF(LEN(A2)<=6,A2,LEFT(A2,LEN(A2)-3))


    A
    B
    1
    Pages Magazine
    2
    Z25 Z25
    3
    X9-8-06 X9-8
    4
    V090-88 V090
    5
    ZZ-555 ZZ-555
    6
    ZZ-55 ZZ-55
    7
    Z555-55 Z555
    8
    ZZZZ ZZZZ
    9
    CX78M CX78M
    10
    Y67 Y67
    11
    K022 K022
    12
    LL78 LL78
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  8. #8
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Formula to Separate Values in Execel

    Here's a formula which does the same as the UDF I posted:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Horrible!

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

    Re: Formula to Separate Values in Execel

    Try this formula with 4 functions (enter into B1):

    =IFERROR(REPLACE(A1,MIN(SEARCH({"-??#","-?#"},A1&"#-??#-?#")),99,""),A1)

  10. #10
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Formula to Separate Values in Execel

    Try:
    =IF(MID(A2,LEN(A2)-2,1)="-",LEFT(A2,LEN(A2)-3),A2)
    Quang PT

+ 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] Splitting formula Values from one cell into separate cells
    By thegrandmaster in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-05-2013, 02:17 AM
  2. Replies: 6
    Last Post: 10-09-2013, 08:20 AM
  3. Formula to separate cell values in a column with commas
    By PuffyGrl82 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-24-2011, 10:15 PM
  4. Replies: 4
    Last Post: 06-03-2009, 04:59 PM
  5. What formula will read 2 separate values and give me a 3rd value?
    By VinnyG in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-13-2005, 06:37 PM

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