+ Reply to Thread
Results 1 to 29 of 29

combine columns datas for identical values in first column

Hybrid View

  1. #1
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,222

    Re: combine columns datas for identical values in first column

    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")))
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    04-21-2012
    Location
    rome, italy
    MS-Off Ver
    365
    Posts
    132

    Re: combine columns datas for identical values in first column

    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.
    Attached Files Attached Files

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,769

    Re: combine columns datas for identical values in first column

    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!
    Attached Files Attached Files
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

+ 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] Code runs in small datas but not working perfectly in bigger datas
    By RAJESH SHAH in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-04-2021, 10:28 PM
  2. [SOLVED] Getting datas every 3 rows
    By RoD69 in forum Excel General
    Replies: 8
    Last Post: 10-01-2013, 04:51 AM
  3. compare oracle table datas and excel datas
    By james94539 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-01-2013, 03:48 PM
  4. Import Datas
    By shyam sundar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-21-2013, 02:56 PM
  5. datas in workbook 2 is not getting updated when datas in workbook 1 is changed
    By share knowledge in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-04-2011, 12:21 PM
  6. sort certain datas in a wide range of datas
    By go4cdt in forum Excel General
    Replies: 2
    Last Post: 03-20-2006, 12:45 PM
  7. re : Finding the datas and deleting datas which are not found.
    By ddiicc in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-30-2005, 09: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