+ Reply to Thread
Results 1 to 9 of 9

Merge city names from 4 columns into one column with "/" between each city

  1. #1
    Forum Contributor
    Join Date
    02-12-2014
    Location
    al ain
    MS-Off Ver
    Excel 2016
    Posts
    149

    Merge city names from 4 columns into one column with "/" between each city

    Hi guys,
    Please help me remove those extra "/" signs between the cities..
    Thanks
    Attached Files Attached Files

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Merge city names from 4 columns into one column with "/" between each city

    Try this instead...
    =SUBSTITUTE(TRIM(A2&" "&B2&" "&C2&" "&D2)," ","/")
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,756

    Re: Merge city names from 4 columns into one column with "/" between each city

    Ford - is that going to put a forward slash between New and York?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Merge city names from 4 columns into one column with "/" between each city

    hmm yup it does

  5. #5
    Forum Contributor
    Join Date
    02-12-2014
    Location
    al ain
    MS-Off Ver
    Excel 2016
    Posts
    149

    Re: Merge city names from 4 columns into one column with "/" between each city

    it displays "New York" as "New/York"
    Other than that works fine.

  6. #6
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Merge city names from 4 columns into one column with "/" between each city

    hi alipezu. without using programming, try:
    =SUBSTITUTE(IF(A2<>"","/"&A2,"")&IF(B2<>"","/"&B2,"")&IF(C2<>"","/"&C2,"")&IF(D2<>"","/"&D2,""),"/","",1)

    if you have a lot of columns, you might want to consider using VBA. a member of the forum, tigeravatar came up with this:
    http://www.excelforum.com/tips-and-t...geravatar.html
    Post #8 should be the final code you can use.

    How to install your new code
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Press Alt+F11 to open the Visual Basic Editor
    Choose Insert > Module
    Edit > Paste the macro into the module that appeared
    Close the VBEditor
    Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    use:
    =ConcatAll(IF(A2:D2<>"",A2:D2,""),"/")
    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Merge city names from 4 columns into one column with "/" between each city

    OK this got messy...
    =SUBSTITUTE(A2&IF(A2="","","/")&B2&IF(B2="","","/")&C2&IF(C2="","","/")&D2,"/","",COUNTA(A2:D2))

  8. #8
    Forum Contributor
    Join Date
    02-12-2014
    Location
    al ain
    MS-Off Ver
    Excel 2016
    Posts
    149

    Re: Merge city names from 4 columns into one column with "/" between each city

    This link http://www.excelforum.com/tips-and-t...geravatar.html is dead..
    Although the first method worked fine for me..
    Thank you benishiryo
    Also thank to FDibbins

  9. #9
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Merge city names from 4 columns into one column with "/" between each city


+ 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] Finding most common "city" in a column and present how many
    By sealpino in forum Excel General
    Replies: 11
    Last Post: 03-14-2017, 02:27 PM
  2. [SOLVED] How can I get country name based on city names in the columns
    By alipezu in forum Excel General
    Replies: 10
    Last Post: 11-29-2016, 02:50 AM
  3. Replies: 3
    Last Post: 02-07-2016, 03:58 AM
  4. [SOLVED] Extract city and state by using "/" divider
    By zeroist in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-26-2014, 10:05 AM
  5. Calculating Shipment Rates Base on Origin City and Destination City
    By Chnatko in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-09-2014, 11:11 AM
  6. extract city using city list lookup
    By terrysoper1973 in forum Excel General
    Replies: 1
    Last Post: 09-07-2011, 01:43 PM
  7. Not changing from "City" to "1-City"
    By Steved in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-05-2005, 02:10 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