+ Reply to Thread
Results 1 to 6 of 6

Split column by last character without any delimiter where strings varies in length

Hybrid View

  1. #1
    Registered User
    Join Date
    04-17-2020
    Location
    Sweden
    MS-Off Ver
    Office 365
    Posts
    24

    Split column by last character without any delimiter where strings varies in length

    Hi,
    I would like to split a column by the last character. These strings doesn't contain any delimiters and varies in length. The last character should be subtracted from the first column. Like this:

    If A1 contains the word "BAKERY", I would like A1 to be left with "BAKER" and B1 with "Y".

    I'm aware that this kind of formula could create a circular reference. Is my best shot to use two columns with the the formula (in B1)
    =LEFT(A1, LEN(A1) - 1)
    and (in C1)
    =RIGHT(A1, 1)
    or could this be arranged with a dynamic array function somehow?

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,368

    Re: Split column by last character without any delimiter where strings varies in length

    You cannot change the contents of a cell with a formula - that would require VBA.

    Try this in B1:

    =LET(b,LEFT(A1,LEN(A1)-1),c,RIGHT(A1,1),HSTACK(b,c))

    This would do the whole column (up to row 1000) at once:

    =IFERROR(LET(b,LEFT(A1:A1000,LEN(A1:A1000)-1),c,RIGHT(A1:A1000,1),HSTACK(b,c)),"")
    Attached Files Attached Files
    Last edited by AliGW; 12-27-2023 at 09:57 AM.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    04-17-2020
    Location
    Sweden
    MS-Off Ver
    Office 365
    Posts
    24

    Re: Split column by last character without any delimiter where strings varies in length

    I understand, just as I feared.
    Thank you, this formula was really neat and it works just as I hoped.
    Last edited by AliGW; 12-27-2023 at 10:04 AM. Reason: Please don't quote unnecessarily - use the Quick Reply button instead.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,368

    Re: Split column by last character without any delimiter where strings varies in length

    Did you see the second formula?

    Glad to have helped.

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of each of those who offered help.

  5. #5
    Registered User
    Join Date
    04-17-2020
    Location
    Sweden
    MS-Off Ver
    Office 365
    Posts
    24

    Re: Split column by last character without any delimiter where strings varies in length

    I did, thank you AliGW!

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Split column by last character without any delimiter where strings varies in length

    The second one is not so useful, as you wind up with a pile of blanks in your array. This is better:

    =LET(a,TOCOL(A1:A1000,1),b,LEFT(a,LEN(a)-1),c,RIGHT(a,1),HSTACK(b,c))
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

+ 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. Split Column by delimiter
    By ypurcaro in forum Excel General
    Replies: 5
    Last Post: 08-30-2020, 06:46 PM
  2. [SOLVED] Split a column using comma delimiter
    By brent_milne in forum Excel General
    Replies: 5
    Last Post: 10-09-2019, 01:45 PM
  3. How to split a column at first delimiter only
    By Jonathan78 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-07-2016, 08:32 AM
  4. [SOLVED] Split specific chars in one column to other columns with no delimiter
    By Fjalar in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-21-2013, 12:28 PM
  5. [SOLVED] 2010: random length strings in cell - need to split
    By dhipwood in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-30-2012, 11:46 AM
  6. [SOLVED] Split One Column at Delimiter While Copying Contents of Second Column to Populate New Rows
    By medailSacrosanct in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 08-01-2012, 11:37 AM
  7. Find character when the length varies
    By Rookie_User in forum Excel General
    Replies: 3
    Last Post: 04-12-2006, 02:20 PM

Tags for this Thread

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