VLOOKUP value and return CONCATENATE text by date in several rows

nuficek

Board Regular
Joined
Jul 20, 2016
Messages
54
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a large table with date, ID and text (several columns). I would like to search value in ID column and return concatenate text. That's not so big deal which I can manage. But as there could be more same ID values for several dates. So would like to find this value and join text together in one row by date. So in the first row there will be the first string matching the date, the second row the second string matching the date ...etc. Is there any chance to do that in Excel?

example.xlsx
ABCDEFGHI
1DateIDDATA 1DATA 2SEARCH:ID05
21.9.2021ID01text1text2
32.9.2021ID01text3text4DateDATA
415.9.2021ID05text5text615.9.2021text5 - text6 - text7 -text8
515.9.2021ID05text7text817.9.2021text9 - text10
616.9.2021ID05text9text10
720.9.2021ID33text33text34
Sheet1
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Which Excel version do you have? Could you update your profile?

For office 365:

Excel Formula:
=TEXTJOIN(" - ",TRUE,FILTER($C$2:$D$7,($B$2:$B$7=$G$1)*($A$2:$A$7=F4)))
 
Upvote 0
Which Excel version do you have? Could you update your profile?

For office 365:

Excel Formula:
=TEXTJOIN(" - ",TRUE,FILTER($C$2:$D$7,($B$2:$B$7=$G$1)*($A$2:$A$7=F4)))
Thanks a lot for your quick reply. I have Office 365. Your formula works good but just for the first date. Is there a way to add automatically next row with the second date as in the example. Btw there is a small mistake in my upload so here is the correct one:

example.xlsx
ABCDEFGHI
1DateIDDATA 1DATA 2SEARCH:ID05
21.9.2021ID01text1text2
32.9.2021ID01text3text4DateDATA
415.9.2021ID05text5text615.9.2021text5 - text6 - text7 -text8
515.9.2021ID05text7text816.9.2021text9 - text10
616.9.2021ID05text9text10
720.9.2021ID33text33text34
Sheet1
 
Upvote 0
How about
+Fluff 1.xlsm
ABCDEFG
1DateIDDATA 1DATA 2SEARCH:ID05
201/09/2021ID01text1text2
302/09/2021ID01text3text4DateDATA
415/09/2021ID05text5text615/09/2021text5 - text6 - text7 - text8
515/09/2021ID05text7text816/09/2021text9 - text10
616/09/2021ID05text9text10
720/09/2021ID33text33text34
Lists
Cell Formulas
RangeFormula
F4:F5F4=UNIQUE(FILTER(A2:A7,B2:B7=G1))
G4:G5G4=TEXTJOIN(" - ",,FILTER($C$2:$D$7,($B$2:$B$7=$G$1)*($A$2:$A$7=F4)))
Dynamic array formulas.
 
Upvote 0
Try to run this macro to generate all at once.

VBA Code:
Sub jec()
 ar = Sheets(1).Range("A1:D7")
 With CreateObject("scripting.dictionary")
    For i = 2 To UBound(ar)
      If ar(i, 2) = Sheets(1).Range("G1") Then .Item(ar(i, 1)) = .Item(ar(i, 1)) & IIf(.exists(ar(i, 1)), " - ", "") & ar(i, 3) & " - " & ar(i, 4)
    Next
   Sheets(1).Cells(4, 6).Resize(.Count, 2) = Application.Transpose(Array(.keys, .items))
 End With
End Sub
 
Upvote 0
Try to run this macro to generate all at once.

VBA Code:
Sub jec()
 ar = Sheets(1).Range("A1:D7")
 With CreateObject("scripting.dictionary")
    For i = 2 To UBound(ar)
      If ar(i, 2) = Sheets(1).Range("G1") Then .Item(ar(i, 1)) = .Item(ar(i, 1)) & IIf(.exists(ar(i, 1)), " - ", "") & ar(i, 3) & " - " & ar(i, 4)
    Next
   Sheets(1).Cells(4, 6).Resize(.Count, 2) = Application.Transpose(Array(.keys, .items))
 End With
End Sub
Unfortunately VBA code doesn't work for me. But it seems to be the best and easiest solution.
 
Upvote 0
Have you tried the formula I suggested?
 
Upvote 0
Y
Have you tried the formula I suggested?
Yes I tried. But when I change the data for ID01 the second row is wrong:

example.xlsm
ABCDEFGHI
1DateIDDATA 1DATA 2SEARCH:ID01
21.9.2021ID01text1text2
32.9.2021ID01text3text4DateDATA
415.9.2021ID05text5text61.9.2021text1 - text2
515.9.2021ID05text7text82.9.2021text9 - text10
616.9.2021ID05text9text10
720.9.2021ID33text33text34
Sheet1
Cell Formulas
RangeFormula
F4:F5F4=UNIQUE(FILTER(A2:A7,B2:B7=G1))
G4G4=TEXTJOIN(" - ",,FILTER($C$2:$D$7,($B$2:$B$7=$G$1)*($A$2:$A$7=F4)))
Dynamic array formulas.
 
Upvote 0
You need to drag the formula in G4 down.
 
Upvote 0

Forum statistics

Threads
1,215,465
Messages
6,124,977
Members
449,200
Latest member
Jamil ahmed

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