+ Reply to Thread
Results 1 to 4 of 4

Combine unique text cells, if the number next to it is greater than 0

  1. #1
    Registered User
    Join Date
    07-27-2017
    Location
    United State
    MS-Off Ver
    2010
    Posts
    2

    Combine unique text cells, if the number next to it is greater than 0

    Hello, I'm posting to the VBA forum as I've been unable to solve this issue on my own using only formulas. I'm a VBA novice, so I'm hoping I'll be able to understand the insights you all have.

    I have a list of unique words, and next to each unique word are multiple columns with numbers. I'd like to combine all of the unique words, where the numbers next to it are greater than 0, into a single cell, with each word separated by a + sign.

    For each column of numbers, I want a different result.

    For example:

    Apple / 1 / 0 / 1
    Orange / 3 / 1 / 1
    Pear / 0 / 0 / 2

    In the above example

    Result 1:
    Apple+Orange

    Result 2:
    Orange

    Result 3:
    Apple+Orange+Pear

    Above each column of numbers is a sequential identifier, such as "001", "002", "003". On another sheet, where I want the unique words combined, I will have this sequence. So, where 001 appears, it looks at 001, scans down, finds the numbers greater than 0, pulls those words, and combines them with a + in between.

    Is there a way for me to accomplish this?

  2. #2
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: Combine unique text cells, if the number next to it is greater than 0

    This could be done by formulas with the use of helper cells which basically goes:
    IF (value = 0, prior_text , prior_text & "+" & current_text)
    Then in the next sheet, something that selects the end results.

    Without seeing the actual file, I can only whip up a quick example to approach. May or may not be easily transferable to your file. See attach for reference.
    Attached Files Attached Files

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Combine unique text cells, if the number next to it is greater than 0

    Hi 2990 and welcome to the forum,

    In Excel 2016 there is a new function called TextJoin() that makes your problem a little simpler. If you had 2016 then you could replace the numbers with the words, if they weren't zero. Then use TextJoin to build your answer. I'll attach my answer and method here for others who have the newer version of Excel.

    TextJoin Answer.xlsx
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Registered User
    Join Date
    07-27-2017
    Location
    United State
    MS-Off Ver
    2010
    Posts
    2

    Re: Combine unique text cells, if the number next to it is greater than 0

    Quote Originally Posted by quekbc View Post
    This could be done by formulas with the use of helper cells which basically goes:
    IF (value = 0, prior_text , prior_text & "+" & current_text)
    Then in the next sheet, something that selects the end results.

    Without seeing the actual file, I can only whip up a quick example to approach. May or may not be easily transferable to your file. See attach for reference.
    Hi Quekbc, thank you - this worked for me. Took me a little bit to wrap my head around the double if statement, but your explanation and attachment helped a lot!

    Quote Originally Posted by MarvinP View Post
    Hi 2990 and welcome to the forum,

    In Excel 2016 there is a new function called TextJoin() that makes your problem a little simpler. If you had 2016 then you could replace the numbers with the words, if they weren't zero. Then use TextJoin to build your answer. I'll attach my answer and method here for others who have the newer version of Excel.

    Attachment 530380
    It looks like I need to upgrade then, as that is just what I was looking for! Thank you for that insight.

+ 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. How to combine 2 cells text into number
    By huangyi1316 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-22-2015, 06:57 PM
  2. Replies: 4
    Last Post: 10-24-2012, 10:54 AM
  3. Replies: 2
    Last Post: 03-27-2012, 03:02 PM
  4. Replies: 1
    Last Post: 12-29-2009, 12:46 PM
  5. Counting unique text/number cells from a range
    By sudeepd12 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 09-06-2005, 07:05 AM
  6. Counting unique text/number cells from a range
    By sudeepd12 in forum Excel General
    Replies: 3
    Last Post: 06-15-2005, 02:58 PM
  7. Counting unique text/number cells from a range
    By sudeepd12 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-14-2005, 07:05 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