+ Reply to Thread
Results 1 to 11 of 11

=CONCATENATE problem

Hybrid View

  1. #1
    Registered User
    Join Date
    06-14-2018
    Location
    UK
    MS-Off Ver
    2017
    Posts
    16

    =CONCATENATE problem

    Hi all

    I am trying to use =CONCATENATE to join together a list of names IF they fit a criteria. I don't seem to be able to get it to work with countifs though. I'd appreciate it if anyone is able to help.

    Thanks in advance for any help!

    Here's what I need to happen


    Pseudo code version:
    Go down column A and check how many for "Spelling" as a category
    If spelling = true, add the name in column B to the string
    move to the next instance of spelling in A & loop
    Output all of the names of those who need spelling help into a string

    Picture version:
    PictureVersion.png

  2. #2
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: =CONCATENATE problem

    Could you attached sample file as on picture, please?
    Let's try:
    As I see you've got excel2017, so you don't have a TEXTJOIN function, then use this macro:

    Public Function textjoinSUB(ByVal varData As Variant, Optional ByVal sDelimiter As String = vbNullString, Optional ByVal bUnique As Boolean = False) As String
    'Created by TigerAvatar at www.excelforum.com, September 2012
    'Purpose is to concatenate many strings into a single string
    'Can be used with arrays, range objects, and collections
        
        Dim DataIndex As Variant    'Used to loop through arrays, range objects, and collections
        Dim strResult As String     'Used to build the result string
        
        'Test if varData is an Array, Range, or Collection
        If IsArray(varData) _
        Or TypeOf varData Is Range _
        Or TypeOf varData Is Collection Then
            
            'Found to be an, array, range object, or collection
            'Loop through each item in varData
            For Each DataIndex In varData
                'Check if the item isn't empty
                If Len(DataIndex) > 0 Then
                    'Found the item isn't empty, check if user specified bUnique as True
                    If bUnique = True Then
                        'bUnique is true, check if the item has been included in the result yet
                        If InStr(1, "||" & strResult & "||", "||" & DataIndex & "||", vbTextCompare) = 0 Then
                            'Item has not been included in the result, add item to the result
                            strResult = strResult & "||" & DataIndex
                        End If
                    Else
                        'bUnique is not true, add item to the result
                        strResult = strResult & "||" & DataIndex
                    End If
                End If
            Next DataIndex
            
            'Correct strResult to remove beginning delimiter and convert "||" to the specified sDelimiter
            strResult = Replace(Mid(strResult, 3), "||", sDelimiter)
            
        Else
            'Found not to be an array, range object, or collection
            'Simply set the result = varData
            strResult = varData
        End If
        
        'Output result
        textjoinSUB = strResult
        
    End Function
    and into C2:
    =textjoinSUB(IF(A2:A10="Spelling",B2:B10,""),", ",1)
    and into D2:
    =textjoinSUB(IF(A2:A10="Addition",B2:B10,""),", ",1)
    both formulas have to be accepted with Ctrl+Sfhift+Enter as both are array formulas.

    Should works.
    Last edited by KOKOSEK; 04-18-2019 at 11:05 AM.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  3. #3
    Registered User
    Join Date
    06-14-2018
    Location
    UK
    MS-Off Ver
    2017
    Posts
    16

    Re: =CONCATENATE problem

    KOKOSEK, thanks so much! A really slick answer. I think (hope) all users will be able to use a macro enabled workbook. If not i might come back and ask if we can do it without macros. Your solution saves me a lot of ctrl+ clicking to use concatenate though so I prefer it!

    Thanks again

  4. #4
    Registered User
    Join Date
    06-14-2018
    Location
    UK
    MS-Off Ver
    2017
    Posts
    16

    Re: =CONCATENATE problem

    Hi KOKOSEK

    All works fine with the macro so thank you indeed for your help.

    One final thing if I could? In the cell formula, how can I reference text in a cell? I can't seem to get it to work. Here's your version and what I need in my version. I have included a picture to help explain. I am missing something I think. I have tried the INDIRECT function

    Attachment 621183.

    =textjoinSUB(IF(A2:A94="Spelling",B2:B94,""),", ",1) (Your version)

    =textjoinSUB(IF(A2:A94=C1,B2:B94,""),", ",1) (What I need - C1 needs to pull through the word "spelling" to complete the formula)

  5. #5
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: =CONCATENATE problem

    Quote Originally Posted by Tarqish View Post
    =textjoinSUB(IF(A2:A94="Spelling",B2:B94,""),", ",1) (Your version)
    =textjoinSUB(IF(A2:A94=C1,B2:B94,""),", ",1) (What I need - C1 needs to pull through the word "spelling" to complete the formula)
    Are you sure that you accept formulas with Ctrl+Shift+Enter after you've changed it into C1?
    I don't have any problems with it.

    Capture.JPG

  6. #6
    Registered User
    Join Date
    06-14-2018
    Location
    UK
    MS-Off Ver
    2017
    Posts
    16

    Re: =CONCATENATE problem

    oops! All sorted. Thanks

  7. #7
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,706

    Re: =CONCATENATE problem

    whilst you might not have TEXTJOIN you should likely have CONCAT, so a formula based alternative might be:

    =REPLACE(CONCAT(INDEX(REPT(","&$B$2:$B$6,$A$2:$A$6=C$1),0)),1,1,"")

    above assumes, per your latest post, that C1 contains "Spelling"

    if the above returns #NAME? then best to persist with the UDF.

  8. #8
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: =CONCATENATE problem

    You welcome.
    If you happy with solution, please use Thread tools and mark thread as SOLVED.
    Last edited by KOKOSEK; 04-23-2019 at 10:54 AM.

  9. #9
    Registered User
    Join Date
    06-14-2018
    Location
    UK
    MS-Off Ver
    2017
    Posts
    16

    Re: =CONCATENATE problem

    Sorry, one more question before I put the thread as solved if I may KOKOSEK and sorry to ask what may be a very simple question:

    I need to be able to check another field to return a slightly altered list. Basically produce the list we have already done in Cell D4 and then list those who have "Yes" in column C in E4. My If/And statement does not yield a result so I am missing something.

    I have attached another picture.

    2.png

    If you prefer me to create a a new post, please let me know.

    Thanks
    Tarq
    Last edited by Tarqish; 04-23-2019 at 05:10 PM.

  10. #10
    Registered User
    Join Date
    06-14-2018
    Location
    UK
    MS-Off Ver
    2017
    Posts
    16

    Re: =CONCATENATE problem

    Never mind. Sorted it... had to use two nested ifs rather than an AND.

    Thanks for all your help!

  11. #11
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: =CONCATENATE problem

    Into E3 (those trained)
    Formula: copy to clipboard
    =textjoinSUB(IF((A3:A8=D1)*(C3:C8="Yes"),B3:B8,""),", ",1)

    of course accepted by Ctrl+Shift+Enter.

    Capture.JPG

+ 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. [SOLVED] Concatenate Problem
    By dcningbo in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-18-2014, 03:46 PM
  2. Name CONCATENATE Problem
    By mohan.r1980 in forum Excel General
    Replies: 3
    Last Post: 02-24-2012, 04:20 AM
  3. VBA Concatenate problem
    By mcinnes01 in forum Excel Programming / VBA / Macros
    Replies: 46
    Last Post: 11-05-2010, 06:00 AM
  4. Concatenate Problem
    By tshirttom in forum Excel General
    Replies: 7
    Last Post: 03-06-2008, 03:42 PM
  5. Concatenate Problem
    By jcbcmc in forum Excel General
    Replies: 2
    Last Post: 06-25-2007, 11:47 AM
  6. concatenate problem
    By Norbert Jaeger in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-19-2005, 06:50 AM
  7. concatenate problem
    By joe peters in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-28-2005, 06: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