+ Reply to Thread
Results 1 to 8 of 8

Break Text into 6 groups

  1. #1
    Forum Contributor
    Join Date
    11-12-2012
    Location
    Jeddah, Saudi Arabia
    MS-Off Ver
    2010, 2013, 2016, Office 365
    Posts
    507

    Break Text into 6 groups

    hi,

    I need a macro to add a space between text in col C. Each text in col C is always 24 characters in length. I need to insert a space after each 4 character. The original text is in this format SA4810000035258281000105 and once I enter the data in column C, I need the target cell text to convert in this format SA48 1000 0035 2582 8100 0105

  2. #2
    Valued Forum Contributor
    Join Date
    07-14-2017
    Location
    Poland
    MS-Off Ver
    Office 2010
    Posts
    528

    Re: Break Text into 6 groups

    Try the UDF function.
    In sheet, D2 formula =Text_Space(C2)
    Please Login or Register  to view this content.
    Best Regards,
    Maras.

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Break Text into 6 groups

    Hi Barieq,

    Here is the Non-VBA answer to your problem:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Break by Space.xlsx
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Forum Contributor
    Join Date
    11-12-2012
    Location
    Jeddah, Saudi Arabia
    MS-Off Ver
    2010, 2013, 2016, Office 365
    Posts
    507

    Re: Break Text into 6 groups

    Thanks @maras_mak and @MarvinP for the solution. Actually I need a worksheet event code Target Column [C] and target cell text to convert to the desired format.

  5. #5
    Forum Contributor
    Join Date
    11-12-2012
    Location
    Jeddah, Saudi Arabia
    MS-Off Ver
    2010, 2013, 2016, Office 365
    Posts
    507

    Re: Break Text into 6 groups

    hi,

    below is the code written by @Jindon to add space after every 4 digits. It works fine if there is only numbers but not alphabets. How I can amend the code to get the below result.

    SA48 1000 0035 2582 8100 0105

    Please Login or Register  to view this content.

  6. #6
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Break Text into 6 groups

    try changing \d{4} to .{4}

  7. #7
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Break Text into 6 groups

    Please try

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    11-12-2012
    Location
    Jeddah, Saudi Arabia
    MS-Off Ver
    2010, 2013, 2016, Office 365
    Posts
    507

    Re: Break Text into 6 groups

    Thanks @XLent and @Bo_Ry, Both the code is working great. Thanks to all who helped to solve this thread.

+ 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. Replies: 1
    Last Post: 06-04-2019, 03:46 PM
  2. Check If a Cells Contains Groups of Text
    By Mark123456789 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-06-2018, 03:35 PM
  3. How to find if a text is higher than another text in groups
    By Stewie12345 in forum Excel General
    Replies: 17
    Last Post: 12-16-2016, 10:21 AM
  4. [SOLVED] Struggling to sort matching orders into groups & add product names to break lines between.
    By RaptureAG in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-24-2014, 09:06 AM
  5. code to break a number down into groups
    By Traymond in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-10-2009, 10:57 PM
  6. [SOLVED] expand groups while searching for a text
    By arpit in forum Excel General
    Replies: 0
    Last Post: 03-12-2006, 07:10 PM
  7. [SOLVED] permutations of text groups?
    By green fox in forum Excel General
    Replies: 0
    Last Post: 04-27-2005, 01:06 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