+ Reply to Thread
Results 1 to 7 of 7

How to conditionally concatenate in Excel 2016

  1. #1
    Registered User
    Join Date
    03-27-2019
    Location
    London, England
    MS-Off Ver
    Excel 2016
    Posts
    4

    Exclamation How to conditionally concatenate in Excel 2016

    Hi all,

    I am using Excel 2016 and I want to concatenate values based on their value.

    Basically, imagine a column which contains all the values in different rows. Each row of that column has one value. Some values are positive and some are negative.
    I want to concatenate two values and drag this formula down. However, if one of these two values is negative then I dont want the concatenation. In other words, I want to find the next positive value to apply the formula.

    Can anyone please help me?

    I have attached an example. Column A includes the values and Column B includes what I want.

    Thanks in advance,
    Marios
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: How to conditionally concatenate in Excel 2016

    Try, in B3 copied down
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    03-27-2019
    Location
    London, England
    MS-Off Ver
    Excel 2016
    Posts
    4

    Re: How to conditionally concatenate in Excel 2016

    I forgot to mention that consecutive rows can have negative values. Otherwise, it would be easy to just apply a condition if formula.

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,733

    Re: How to conditionally concatenate in Excel 2016

    Using a helper column (C), put this formula in C2:

    =IF(A2<=0,"",COUNTIF(A:A,">0")-COUNT(C$1:C1))

    and copy this down to the bottom of your data. Then in B2 you can use this formula:

    =IF(OR(C2=MAX(C:C),C2=""),"",A2&"-"&INDEX(A:A,MATCH(C2+1,C:C,0)))

    and copy this down.

    Hope this helps.

    Pete

  5. #5
    Registered User
    Join Date
    03-27-2019
    Location
    London, England
    MS-Off Ver
    Excel 2016
    Posts
    4

    Re: How to conditionally concatenate in Excel 2016

    Hi ChemistB,

    Thanks for this. Actually, I made a mistake. Instead of concatenating Node B to Node A I want the opposite(instead of concatenating row 3 to row 2, I want row 2 to row 3). Please see the example_corrected spreadsheet.

    How would this work now?
    Attached Files Attached Files

  6. #6
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: How to conditionally concatenate in Excel 2016

    Please try at B3
    =IF(A3<0,"",-LOOKUP(0,-A$2:A2)&"-"&A3)

  7. #7
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,733

    Re: How to conditionally concatenate in Excel 2016

    If you take my suggested approach, you can have the same formula in C2 (copied down) and this one in B2:

    =IF(OR(C2=MAX(C:C),C2=""),"",INDEX(A:A,MATCH(C2+1,C:C,0))&"-"&A2)

    which just reverses the order.

    Hope this helps.

    Pete

+ 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. Concatenate 2 Dates Conditionally Using Another Cell
    By chiatbw in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-20-2017, 08:05 AM
  2. Replies: 1
    Last Post: 09-18-2017, 08:27 AM
  3. [SOLVED] Issue send email with excel 2016 true outlook 2016
    By kirana2014 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-12-2017, 11:34 AM
  4. Help! Automated Email coding for Excel 2016 and Outlook 2016 problems
    By lisa6421 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-01-2017, 08:07 AM
  5. [SOLVED] conditionally concatenate values in second table
    By kammend in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-27-2016, 11:44 AM
  6. [SOLVED] How to concatenate mutiple rows and show it in a single Cell Conditionally
    By Kandavalli.Kiran in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-04-2015, 04:48 PM
  7. [SOLVED] how do i concatenate conditionally formatted cells in excel
    By Sandwiches2 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-13-2006, 09:45 PM

Tags for this Thread

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