+ Reply to Thread
Results 1 to 4 of 4

Adding spaces to every third letter in a string

  1. #1
    Registered User
    Join Date
    12-29-2010
    Location
    Ottawa, Canada
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    20

    Adding spaces to every third letter in a string

    Hi,

    I'd like to create a custom cell format. I have strings of various lengths in individual cells and I want to show them with a space in-between every third letter. The strings can be anywhere from 12 to 26 characters in length.

    One example:

    Original: CTTCTGACACCGCTGGTCTG
    After custom formatting: CTT CTG ACA CCG CTG GTC TG


    Any suggestions would be greatly appreciated!

    Thanks
    Last edited by Einstahb; 09-01-2011 at 03:48 PM.

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Adding spaces to every third letter in a string

    You can't do that with cell formatting.

    One way is to use a formula in another cell, e.g. with data in A1 use this formula in B1

    =TRIM(MID(A1,1,3)&" "&MID(A1,4,3)&" "&MID(A1,7,3)&" "&MID(A1,10,3)&" "&MID(A1,13,3)&" "&MID(A1,16,3)&" "&MID(A1,19,3)&" "&MID(A1,22,3)&" "&MID(A1,25,3))
    Audere est facere

  3. #3
    Registered User
    Join Date
    12-29-2010
    Location
    Ottawa, Canada
    MS-Off Ver
    Excel 2004 for Mac
    Posts
    20

    Re: Adding spaces to every third letter in a string

    That worked well!

    It would still be nice if a format could be added to avoid the need of an additional column. But if it's not possible, there's not much else I can do, I suppose.

    Thanks for the quick reply!

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Adding spaces to every third letter in a string

    Once you have the results, you can copy that column back over your original using Paste Special> Values and then clear the second column.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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