+ Reply to Thread
Results 1 to 6 of 6

Concatinating with if statements

  1. #1
    Registered User
    Join Date
    01-31-2013
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    4

    Concatinating with if statements

    Hello!

    I have gigantic spreadsheet with about 20 columns and thousands of rows. I'm only going to give a subset of the problem to make this easier.

    Columns B, C & D are categories that can be assigned values. I want to add a column, E that lists the names of the column, if the row has a value in that column.

    e.g.


    A B C D E
    1 0 0 0
    2 1 0 0 B
    3 5 2 1 B/C/D
    4 0 2 4 C/D
    5 0 0 2 D

    currently I've added hidden rows F,G,H. They return the names of "B","C","D" as a string if B,C,D is a non-zero value. Then column E concats(F,"/",G,"/"H).

    This is not a very elegant solution and leaves me with extraneous "/" if all three columns do not have values. Does anyone have any other ideas of how to do this? Eventually, I will be adding more conditions, and I'd like to figure out how to use if and concat together.

    Thank you!

  2. #2
    Forum Contributor thameem127's Avatar
    Join Date
    04-06-2012
    Location
    Jeddah,Saudi Arabia
    MS-Off Ver
    Excel 2003,Excel 2007
    Posts
    321

    Re: Concatinating with if statements

    upload ur file

  3. #3
    Forum Contributor thameem127's Avatar
    Join Date
    04-06-2012
    Location
    Jeddah,Saudi Arabia
    MS-Off Ver
    Excel 2003,Excel 2007
    Posts
    321

    Re: Concatinating with if statements

    try this formula =IF(B2<>0,IF(C2<>0,IF(D2<>0,CONCATENATE(F2,G2,H2))))

  4. #4
    Forum Contributor thameem127's Avatar
    Join Date
    04-06-2012
    Location
    Jeddah,Saudi Arabia
    MS-Off Ver
    Excel 2003,Excel 2007
    Posts
    321

    Re: Concatinating with if statements

    See the solution here concatenate.xlsx

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

    Re: Concatinating with if statements

    if cells f g h have no spaces in their values/strings
    =SUBSTITUTE(TRIM(F1&" "&G1&" "&H1)," ","/")
    it they do then a longer
    =SUBSTITUTE(SUBSTITUTE(TRIM(SUBSTITUTE(F10," ","^")&" "&SUBSTITUTE(G10," ","^")&" "&SUBSTITUTE(H10," ","^"))," ","/"),"^"," ")
    see attached
    Attached Files Attached Files
    Last edited by martindwilson; 02-21-2014 at 12:18 PM.
    "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

  6. #6
    Registered User
    Join Date
    01-31-2013
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Concatinating with if statements

    =IF(AND(NOT(B1=0),(C1=0),(D1=0)),"B",IF(AND(NOT(B1=0),NOT(C1=0),(D1=0)),"B/C",IF(AND(NOT(B1=0),NOT(C1=0),NOT(D1=0)),"B/C/D",IF(AND((B1=0),NOT(C1=0),(D1=0)),"C",IF(AND((B1=0),NOT(C1=0),NOT(D1=0)),"C/D",IF(AND((B1=0),(C1=0),NOT(D1=0)),"D",""))))))


    This works too. But I'd rather not list out each condition as it is going to eventually be more complicated.
    Attached Files Attached Files
    Last edited by Anzibanonzi; 02-21-2014 at 12:22 PM. Reason: wrong formula

  7. #7
    Registered User
    Join Date
    01-31-2013
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Concatinating with if statements

    That works well too! Thank you!

+ 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. Concatinating row values with a coma
    By Ahazin01 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-09-2013, 09:38 AM
  2. Concatinating dates in a string of data.
    By Lyle Sass in forum Excel General
    Replies: 2
    Last Post: 06-26-2013, 03:17 PM
  3. Concatinating inside MATCH
    By ChemistB in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-29-2007, 11:22 AM
  4. Concatinating a string of numbers - how?
    By drod in forum Excel General
    Replies: 5
    Last Post: 08-02-2006, 05:10 PM
  5. [SOLVED] Concatinating cells
    By Praveen in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-11-2005, 05:05 AM

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