+ Reply to Thread
Results 1 to 9 of 9

Remove all characters before or after X# of characters

  1. #1
    Forum Contributor
    Join Date
    05-29-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    2021
    Posts
    205

    Remove all characters before or after X# of characters

    I need to enter data in 2 columns that have a character limit of 30 each. My data has more than 30 characters. I'm looking for a formula that can trim my data and keep everything <= 30 characters in column A, then a second formula to put everything that's >= 31 into column B.

    Thanks!
    Last edited by Ocean Zhang; 07-21-2014 at 11:47 PM.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,731

    Re: Remove all characters before or after X# of characters

    Assuming you already have data in column A, put this formula in B1 to get the first 30 characters:

    =LEFT(A1,30)

    and this one in C1 to get the remaining characters:

    =MID(A1,31,255)

    Copy both formulae down, then fix the values and you can delete the original column A.

    Hope this helps.

    Pete

  3. #3
    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,938

    Re: Remove all characters before or after X# of characters

    Another way would be to use Text2Columns with Fixed Width, move the slider to 30
    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

  4. #4
    Forum Contributor
    Join Date
    05-29-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    2021
    Posts
    205

    Re: Remove all characters before or after X# of characters

    Thanks Pete and Ford! I need to add another wrinkle to this. I realized I needed whole words to be intact. Cutting cells off at exactly 30 characters every time will occasionally bisect a word. How can the formula be modified to get column B to cut off after the last space before reaching 30 characters. Then column C to pick up where column B left off?

    Thanks!

  5. #5
    Valued Forum Contributor
    Join Date
    07-07-2014
    Location
    Washington DC
    MS-Off Ver
    2007
    Posts
    1,047

    Re: Remove all characters before or after X# of characters

    Does your data have spaces between each word? Can you upload an example file?

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Remove all characters before or after X# of characters

    Regarding whole words. Does your data have punctuation, "Bob, the district manger, sent an email"
    What do you want done if the last character is punctuation. Eliminate it (so it appears in neither column) or treat it as part of the preceding word?
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  7. #7
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Remove all characters before or after X# of characters

    If you are open to a VBA solution, please find the attached sheet to see if this works as per your requirement. Click the button on sheet1 to split text in col. A as per your requirement.
    Attached Files Attached Files
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  8. #8
    Forum Contributor
    Join Date
    05-29-2009
    Location
    Chattanooga, TN
    MS-Off Ver
    2021
    Posts
    205

    Re: Remove all characters before or after X# of characters

    Thanks sktneer! I love the added touch of the click the button! Saved me the steps of having to go through the developer tab on the ribbon

  9. #9
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Remove all characters before or after X# of characters

    You're welcome. Thanks for the feedback and rep.

+ 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] How to remove characters within (XXX)
    By ElenaAguirre in forum Excel General
    Replies: 2
    Last Post: 04-11-2013, 08:24 AM
  2. Remove some characters
    By Average_JoeMN in forum Excel General
    Replies: 4
    Last Post: 12-08-2011, 12:44 PM
  3. Remove characters
    By miso.dca in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-06-2011, 08:37 AM
  4. Remove characters
    By Blake 7 in forum Excel General
    Replies: 3
    Last Post: 05-17-2011, 07:20 AM
  5. I need to remove characters ...
    By Rick in forum Excel General
    Replies: 2
    Last Post: 08-31-2005, 02:05 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