Please try
=LET(z,test2!C2:F50,p,INDEX(z,,1),t,INDEX(z,,2),CHOOSE({1,2},UNIQUE(FILTER(p,p)),FILTERXML("<x><m>"&SUBSTITUTE(TRIM(CONCAT(IF(t=0," ",t)&TEXT(INDEX(z,,4),"(0);(-0);")))&"</m></x>"," ","</m><m>"),"//m")))
Please try
=LET(z,test2!C2:F50,p,INDEX(z,,1),t,INDEX(z,,2),CHOOSE({1,2},UNIQUE(FILTER(p,p)),FILTERXML("<x><m>"&SUBSTITUTE(TRIM(CONCAT(IF(t=0," ",t)&TEXT(INDEX(z,,4),"(0);(-0);")))&"</m></x>"," ","</m><m>"),"//m")))
Bo-Ry:
i need your help to extend the function.
see attached file.
i need to extract oyher datas from another column ("I") but in two differerent ways.
1)only the last text for a point (you can have nothing or one or more text for a node, in several rows)
2)all the text for a point
in the excel file there is an example (see red text) in the result sheet.
![]()
ub Concat_Points() Dim ar As Variant, arr As Variant Dim i As Long, j As Long, n As Long Dim lastrow As Long, Lastcol As Long Dim str As String Dim ws1 As Worksheet, ws2 As Worksheet Application.ScreenUpdating = False ' ------ sheet di origine dati e destinazione risultati Set ws1 = Worksheets("restraint") Set ws2 = Worksheets("restraint_result") ws1.Activate With ws1 lastrow = .Cells(Rows.Count, 1).End(xlUp).Row Lastcol = .Cells(1, Columns.Count).End(xlToLeft).Column ar = .Range(.Cells(1, 1), .Cells(lastrow, Lastcol)) End With ReDim arr(1 To 4, 1 To 1) n = 0 With CreateObject("Scripting.Dictionary") For i = 2 To UBound(ar, 1) str = ar(i, 3) If str <> "" Then If Not .Exists(str) Then n = n + 1 ReDim Preserve arr(1 To 4, 1 To n) arr(1, n) = str .Item(str) = n End If arr(2, .Item(str)) = arr(2, .Item(str)) & ar(i, 4) If ar(i, 6) <> "" Then arr(2, .Item(str)) = arr(2, .Item(str)) & ar(i, 6) If ar(i, 9) <> "" Then arr(4, .Item(str)) = arr(4, .Item(str)) & ar(i, 9) & "|" End If Next i End With For i = 1 To UBound(arr, 2) If arr(4, i) <> "" Then arr(4, i) = Left(arr(4, i), Len(arr(4, i)) - 1) n = InStr(1, arr(4, i), "|") If n = 0 Then arr(3, i) = arr(4, i) Else arr(3, i) = Mid(arr(4, i), n + 1, 25) End If Next i With ws2 .Activate .Range("A2:D" & .Cells(Rows.Count, 1).End(xlUp).Row).ClearContents .Range("A2").Resize(UBound(arr, 2), UBound(arr, 1)).Value = Application.Transpose(arr) End With Application.ScreenUpdating = True End Sub
NOTE: tab names changed!
If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks