+ Reply to Thread
Results 1 to 8 of 8

Inserting commas into cells with mailing addresses

  1. #1
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173

    Inserting commas into cells with mailing addresses

    I have spreadsheet that contains about 25,000 rows of client addresses. The columns/data is set up as follows for example

    ColumnA...........ColumnB..................ColumnC
    Jim Smith..........123 Apple Road.........New York NY 10022-3456
    Tina Jone..........456 Apple Road.........San Diego CA 12345-1111
    Bob Smith..........789 Peach Lane........Seattle WA 59802-3344
    Tim Smith..........4255 Lime Lane.........Missoula MT 59802-3333

    I am having an issue with the vendor whom needs to do a mailing of all 25,000 clients. They have indicated that they require comma delimited data to create the mailing. In order to do this, I need to place a comma after the city and a comma after the state.

    So as in the first row of data the cells looks like this:

    New York NY 10022-3456

    The vendor needs it to look like this:

    New York, NY, 10022-3456

    Is there a function and/or VBA procedure to put commas in where I need them?

    Thanks.
    Last edited by maacmaac; 12-02-2008 at 11:23 AM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    Assuming cell C2 holds the first set of data, a function to do this is:
    Please Login or Register  to view this content.
    This presumes ALL the data has a 10-digit zip code and a two letter state abbreviation.

    To be honest, what they really want is a comma-delimited file. I wouldn't do it this way. I would split the City / State / Zip into separate columns and then export the data as a comma-delimited file, which will put the commas in for you as the file is saved.

    If you want to do that, just pick three rows to the left, and cut out each of the three sections of code above to get each part:
    Please Login or Register  to view this content.
    Then copy the range and paste over itself Paste Special > Values. Now you can delete the original grouped set and export the data.
    Last edited by JBeaucaire; 12-02-2008 at 12:14 AM. Reason: Removed redundant TRIM commands
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Valued Forum Contributor mdbct's Avatar
    Join Date
    11-11-2005
    Location
    CT
    MS-Off Ver
    2003 & 2007
    Posts
    848
    The follow uses the assumption that not all of your ZIP codes are ZIP +4s.
    in cell D1
    Please Login or Register  to view this content.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    BTW, your sample above included spaces after the added commas. The formula I gave you gives that result. If you really wanted it without the extra spaces:
    Please Login or Register  to view this content.
    This will look like this:

    New York,NY,10022-3456

  5. #5
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173
    JBeaucaire

    I am taking your suggestion to split the City / State / Zip into separate columns and then save the data as a comma-delimited file. This is better for the vendor.

    However, I overlooked the fact that not ALL the data has a 10-digit zip code and a two letter state abbreviation. Some of the data only has a 5-digit code: e.g the data file may look as such:

    New York NY 10022-1234
    Seattle WA 59450
    Seattle WA 59450-4567

    How can I modify your formulas to account for different zip code length? I was thinking that if there is a "-" character in the zip code then use the formula you suggested, else use a different formula.

    Thanks

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    For the varying zip code, use these formulas:

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 12-02-2008 at 10:58 AM. Reason: Formulas were out of order

  7. #7
    Valued Forum Contributor mdbct's Avatar
    Join Date
    11-11-2005
    Location
    CT
    MS-Off Ver
    2003 & 2007
    Posts
    848
    The following will display everything after the last space regardless of the number of character count following the last space:
    Please Login or Register  to view this content.

  8. #8
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173
    It ended up using JBeaucaire's formulas. That was the solution that most closely solved my issue. Thanks to all for comments.

+ 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