+ Reply to Thread
Results 1 to 8 of 8

Merge field with comma after and leave blank

  1. #1
    Registered User
    Join Date
    04-08-2011
    Location
    atlanta, US
    MS-Off Ver
    Excel 2007
    Posts
    7

    Merge field with comma after and leave blank

    Hi,

    I try to merge fields with numbers and field with characters:

    field1 field2 field3 field4 field5 field6
    1040 5027
    1040
    1040 5027 1234
    1040 1234
    1040 1234 1234 1234

    I want to merge all fields to one field and have comma after each field (skip blank fields)
    like merge field for row3 should be 1040, 5027, 1234. Any one have the same problems?

    Thanks in advance for your help.
    Attached Files Attached Files
    Last edited by kittya; 04-11-2011 at 12:01 PM.

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Merge field with comma after and leave blank

    Try this workbook and UDF

    Use the UDF like this

    =Conc(A2:G2,", ")
    Attached Files Attached Files
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  3. #3
    Registered User
    Join Date
    04-08-2011
    Location
    atlanta, US
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Merge field with comma after and leave blank

    they only work without the comma after the merge field; I did like that before but i have to import to access the export to excel then replace space with comma and space to make it work (because excel doesn't eliminate space in the blank field so i have to import to access...)
    1234, 1234, 1243.

  4. #4
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Merge field with comma after and leave blank

    You can use any separator you want with that UDF

    Select the range you need to conncatenate, say A2:G2

    Try like this
    =Conc(A2:G2," | ")

    or even
    =Conc(A12:G18," kittya ")

  5. #5
    Registered User
    Join Date
    04-08-2011
    Location
    atlanta, US
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Merge field with comma after and leave blank

    sorry, I am new here. what do you mean use UDF? is that one of the add-ins?

  6. #6
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Merge field with comma after and leave blank

    No UDF is a User Defined Function.

    To use this you need to do this.

    1/. In Excel, with your workbook open, press Alt+f11 this will take you to the VBa Editor.

    2/. With the "Insert" Tab choose "Module"

    3/. In the resulting window paste all of the following code
    Please Login or Register  to view this content.

    4/. Save the file and close the VBa Editor.

    5/. Select the cell you want the result to appear in
    Now, in the formula bar type
    =Conc(
    and without entering the above, select the range you want to concatenate
    The formula bar will now look, for example, like this
    =Conc(A2:G2
    Type a comma then ", ") (including the quotes)
    The formula bar should look like this
    =Conc(A2:G2,", ")
    Press enter

    If you leave out the sepatator the function will do a straight concatenation
    =Conc(A2:G2)

    As described earlier you can change the separator to what you want, look at the demo workbook to see the examples.

  7. #7
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Merge field with comma after and leave blank

    =substitute(if(a2="","",a2&",")&if(b2="","",b2&",")&if(c2="","",c2&",")&if(d2="","",d2&",")&if(e2="","",e2&",")&if(f2="","",f2&","),",","",counta(a2:f2))
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  8. #8
    Registered User
    Join Date
    04-08-2011
    Location
    atlanta, US
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Merge field with comma after and leave blank

    thanks for your help

+ 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