+ Reply to Thread
Results 1 to 3 of 3

How do I insert commas only when appropriate?

  1. #1
    Registered User
    Join Date
    06-23-2011
    Location
    Columbus, OH
    MS-Off Ver
    Excel 2010
    Posts
    2

    How do I insert commas only when appropriate?

    I use sumifs, vlookups, named ranges, etc on a daily basis but for the life of me I can't figure out the best way to do this.

    I have created several columns in a table to show resources for a project. I'll list a few as an example: column M is Cassie, column N is Tonia, column O is Eric. Then on each row, if that resource is to be used, I have the user put an x in the corresponding cell. I do it this way so I can run pivot tables of the info and so the resources can filter to just their own jobs. The problem is that the manager of this workflow wants to see a comma separated list of resources on each row.

    The best solutions I can think of is
    =if(m2="x","Cassie ","")&if(n2="x","Tonia ","")&if(o2="x","Eric ","")
    This works to list the names, but how would I put a comma in between each without having unnecessary commas? Or, is there a function I don't know of that makes a nice list?

    Thanks,
    John
    Last edited by jhietter; 06-23-2011 at 01:33 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: How do I insert commas only when appropriate?

    Try:

    =SUBSTITUTE(TRIM(IF(M2="x","Cassie"," ")&IF(N2="x","Tonia"," ")&IF(O2="x","Eric"," "))," ",",")

    or if you are copying the formula down try:

    =SUBSTITUTE(TRIM(IF(M2="x",M$1," ")&IF(N2="x",N$1," ")&IF(O2="x",O$1," "))," ",",") copied down assuming M1:O1 contain the 3 names
    Last edited by NBVC; 06-23-2011 at 01:43 PM.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    06-23-2011
    Location
    Columbus, OH
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: How do I insert commas only when appropriate?

    Thank you for your reply! Unfortunately neither one of those work. If you try them you'll see what I mean.
    I think I've talked the manager into accepting them without the comma for now.
    Last edited by romperstomper; 06-24-2011 at 08:11 AM.

+ 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