Combining data with specific criteria

IanPM

Board Regular
Joined
Dec 12, 2013
Messages
53
I have a list of repeating references that I want to combine based on specific criteria in another sheet. Concatenated & transpose is probably part of the requirement but how do I refence it against a specific criteria not using VBA

Output expectation
Column A Columnb
JohnSlow, Fast
KarlFast,Ok,Slow

So I want to have a formula that can combine the below data in Column B based on criteria data in column A above, so that all Column B data is in single cell based on the Column A criteria. The below must be in summary & reflect as above

Below is the data

Column AColumn B
JohnSlow
JohnFast
KarlFast
KarlOk
KarlSlow
 
You need to change the cell reference for each criteria but as I stated in my last post the function needs to be array entered to work as Steve the fish has it and I don't know if there is anything we can do for that.
I'll have a look when I get back in later.
 
Upvote 0

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
If you are able to sort the lookup table by column A and are willing to use a helper column - then here is a formula based option you can try.

Lookup table:
Book1
ABC
1Column AColumn BHelper Column
2JohnSlowSlow
3JohnFastSlow, Fast
4KarlFastFast
5KarlOkFast, Ok
6KarlSlowFast, Ok, Slow
7FredAA
8FredBA, B
Sheet1
Cell Formulas
RangeFormula
C2:C8C2=IF(A2=A1,C1&", "&B2,B2)


Outcome:
Book1
AB
1JohnSlow, Fast
2KarlFast, Ok, Slow
3FredA, B
Sheet2
Cell Formulas
RangeFormula
B1:B3B1=LOOKUP(2,1/(A1=Sheet1!$A$2:$A$8),Sheet1!$C$2:$C$8)
 
Upvote 0
As a backup I will keep it but the structure of the file & data will make it complicated
 
Upvote 0
Ok try the below, remember that the formula must be entered with Ctrl-Shift-Enter and not just Enter. I have also put a test file in the link.

VBA Code:
Function TxtJoin(strLim As String, boolTst As Boolean, ParamArray varArg() As Variant) As Variant 'v2_02

    Dim strTemp As String, strArg As String, dblUB As Double, dblArg As Double, rngCell As Variant

    dblUB = UBound(varArg)

    For dblArg = 0 To dblUB
        strArg = TypeName(varArg(dblArg))

        If strArg = "Range" Or strArg = "Variant()" Then
            For Each rngCell In varArg(dblArg)
                If boolTst = True And rngCell = "" Then
                Else
                    strTemp = strTemp & CStr(rngCell) & strLim
                End If
            Next
        Else
            If boolTst = True And CStr(varArg(dblArg)) = "" Then
            Else
                strTemp = strTemp & CStr(varArg(dblArg)) & strLim
            End If
        End If

    Next

    If strArg = "Error" Then
        TxtJoin = CVErr(xlErrNA)
    Else
        strTemp = IIf(strTemp = "", strLim, strTemp)
        TxtJoin = Left(strTemp, Len(strTemp) - Len(strLim))
    End If

End Function

Book1
ABCD
1Column AColumn B
2JohnSlowJohnSlow,Fast
3JohnFastKarlFast,Ok,Slow
4KarlFast
5KarlOk
6KarlSlow
Sheet2
Cell Formulas
RangeFormula
D2:D3D2{=TXTJOIN(",",TRUE,IF($A$2:$A$6=C2,$B$2:$B$6,""))}
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.


Link to test file (look at Sheet2)
 
Upvote 0

Forum statistics

Threads
1,214,867
Messages
6,122,002
Members
449,059
Latest member
mtsheetz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top