+ Reply to Thread
Results 1 to 4 of 4

Replace SPACE with COMMA Unless preceded by a number or specific text

  1. #1
    Registered User
    Join Date
    06-27-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016
    Posts
    37

    Replace SPACE with COMMA Unless preceded by a number or specific text

    Hi,

    I am looking for some help on a VBA to replace a space with a comma unless it is preceded by a number.

    So on the two following examples...

    47 Fairmile Gardens Longford Gloucester Gloucestershire GL2 9EA,
    354 Finchley Rd Greater London NW3 7AJ

    The result would like like this below

    47 Fairmile Gardens,Longford,Gloucester,Gloucestershire,GL2 9EA ( SPACE not replaced between 47 & Fairmile because it is preceded by a NUMBER, in this case 47, also the SPACE between Fairmile and Gardens not replaced because it is next to the words GARDENS.)
    354 Finchley Rd,Greater London,NW3 7AJ ( SPACE NOT REPLACED BETWEEN 354 & FINCHLEY BECAUSE IT IS PRECEDED BY A NUMBER, IN THIS 354, also the SPACE between Finchley and Rd is not replaced because it is next to Rd. Same concept with Greater London. )

    Any additional words that trigger the ignoring of the replace code need to be able to be added in the code manually.

    Thank you in advance.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    09-02-2020
    Location
    USA
    MS-Off Ver
    2016
    Posts
    76

    Re: Replace SPACE with COMMA Unless preceded by a number or specific text

    Here's a simple way of doing it after selection the data in the sheet.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-27-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016
    Posts
    37

    Re: Replace SPACE with COMMA Unless preceded by a number or specific text

    Thank you so much for the reply. I'll test it out and let you know how I get on.

  4. #4
    Registered User
    Join Date
    06-27-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2016
    Posts
    37

    Re: Replace SPACE with COMMA Unless preceded by a number or specific text

    This worked perfectly first time, thank you once again.

+ 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] Comma Then Space After Each Number In Cell
    By fredfarmer in forum Excel General
    Replies: 3
    Last Post: 04-18-2019, 12:29 PM
  2. [SOLVED] Vlookup value after comma+space and add the values till last comma+space in the series
    By sandeepsandeep in forum Excel Formulas & Functions
    Replies: 49
    Last Post: 12-23-2017, 05:49 AM
  3. [SOLVED] Replace space to comma
    By rarementality in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-13-2014, 09:15 AM
  4. Replies: 5
    Last Post: 10-10-2012, 06:04 AM
  5. Replies: 8
    Last Post: 03-15-2012, 02:27 PM
  6. Replies: 4
    Last Post: 06-05-2006, 01:10 PM
  7. The number in this cell is formatted as text or preceded by an apostrophe
    By Jeremy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-23-2005, 12: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