+ Reply to Thread
Results 1 to 5 of 5

Macro inserting comma & space

  1. #1
    Registered User
    Join Date
    04-26-2009
    Location
    San Antonio, TX
    MS-Off Ver
    Excel 2007
    Posts
    18

    Macro inserting comma & space

    Hello. I am trying to create a macro that will create a comma and space between every 5th character within a cell. I have been unable to get very far at all with that idea, although if anybody can help, that would be preference #1.

    What I decided to go with for now, instead, is to try (using the macro recorder) text to columns, fixed width, and do this after every 5th character, and selecting each cell to be formatted as text.

    What I am having difficulties with is trying to tell the macro which cells to touch and which ones not to. I do not want the macro to do text to columns and fixed width on simple text. I only want it to do the macro when it is a string of numbers that, during transfer from PDF to excel, have been concatenated into one cell. I also want the macro to do this for infinite number of rows. I have excel 2007.

    I am attaching a small excel file with examples of data I am working with. I have saved this excel file as a 97-2003 version for those who do not have 2007.

    As I stated, if anybody can help me figure out how to do a simple insert comma space every 5th character where information has been concatenated, that would be preference. I will gladly take any help at all, though.

    Also, I am not trying to change anything within column A. Only column B. On the sample file please note B3 - B6. Rows 5 & 6 are fine as they are. Other problem rows include B11 - B13

    Thank you!

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by katmison; 09-30-2009 at 03:54 PM. Reason: marking as solved

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Macro inserting comma & space

    Try this:
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    04-26-2009
    Location
    San Antonio, TX
    MS-Off Ver
    Excel 2007
    Posts
    18

    Talking Re: Macro inserting comma & space

    Wow! Absolutely incredible! Thank you so much. Works perfectly. Marking this thread as solved.

  4. #4
    Registered User
    Join Date
    12-21-2011
    Location
    Phila
    MS-Off Ver
    Excel 2003
    Posts
    1

    Lightbulb Re: Macro inserting comma & space

    Would someone be able to help me with creating a macro to RIGHT-Align a column, count 16 characters from the right to the left and insert spaces in between the numeric values and alphabetical values. The only problem is that from the left, I would like to have 6 spaces in. If there is 1, 2 or 3 leading alphabetical characters from the left, skip the characters and add only the spaces after the alphabetical characters but before the numberic values. See examples/results below:

    Before
    C1130119C00004000
    AMR120121C00006000
    ORCL111217C00018000

    After
    C 1130119C00004000
    AMR 120121C00006000
    ORCL 111217C00018000

    Any assistance would be greatly appreciate.

  5. #5
    Registered User
    Join Date
    11-29-2012
    Location
    Estados Unidos
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Macro inserting comma & space

    Man I know I am being lazy but have tried my best to modify your macro since I know it has to be simple to do .. I have a column with 10 digits I need to create a macro that puts a comma and a space after the 3rd digit I can get your macro to add the comma and the space but the other 7 digits erase any help would be appreciated.

    simple one column of phone numbers
    9999991111

    needs to be
    999, 9991111

    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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