Results 1 to 4 of 4

Help me consolidate excel text data

Threaded View

  1. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Help me consolidate excel text data

    One way:

    Public Function ConcatAll(ByVal varData As Variant, Optional ByVal sDelimiter As String = vbNullString, Optional ByVal bUnique As Boolean = False) As String
       
        Dim DataIndex As Variant
        Dim strResult As String
        
        If IsArray(varData) _
        Or TypeOf varData Is Range _
        Or TypeOf varData Is Collection Then
            
            For Each DataIndex In varData
                If Len(DataIndex) > 0 Then
                     If bUnique = True Then
                          If InStr(1, "||" & strResult & "||", "||" & DataIndex & "||", vbTextCompare) = 0 Then
                           trResult = strResult & "||" & DataIndex
                        End If
                    Else
                        strResult = strResult & "||" & DataIndex
                    End If
                End If
            Next DataIndex
            
            strResult = Replace(Mid(strResult, 3), "||", sDelimiter)
            
        Else
            strResult = varData
        End If
        
        ConcatAll = strResult
        
    End Function
    How to install your new code
    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Press Alt+F11 to open the Visual Basic Editor
    Choose Insert > Module
    Edit > Paste the macro into the module that appeared
    Close the VBEditor
    Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)


    Then... In I11, copied across and down:
    =IFERROR(INDEX(A:A,AGGREGATE(15,6,ROW($A$2:$A$10)/(($A$2:$A$10<>"")*(COUNTIF($I$10:$I10,$A$2:$A$10)=0)),1)),"")

    and in J11, an array formula, copied down:
    =IF(I11="","",concatall(IF($A$2:$A$10=I11,$C$2:$C$10&" ("&$D$2:$D$10&")",""),CHAR(10)))

    Don't forget to wrap text in column J, or manually set row width to be deep enough.

    Array formulae are a little different from ordinary formulae in that they MUST be confirmed in the FIRST CELL ONLY by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. After that, the array can be dragged down as normal, to cover the desired range.

    You will know the array is active when you see the curly brackets { } appear around the outside of your formula. If you do not use CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly brackets yourself - it won't work...
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 4
    Last Post: 01-16-2014, 05:59 PM
  2. [SOLVED] Consolidate text data from rows into columns
    By joevan1 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-29-2013, 01:10 AM
  3. Consolidate text data from multiple tabs into one table
    By neversummer515 in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 02-01-2013, 05:52 PM
  4. Replies: 1
    Last Post: 01-08-2013, 03:47 AM
  5. Replies: 20
    Last Post: 10-19-2012, 04:35 PM
  6. Simple macro to consolidate text data worksheets into a master one. beginner, no clue
    By Mayyalondon in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-06-2012, 10:38 AM
  7. Can't consolidate non-data (ie text) cells from worksheets
    By Tim80 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-19-2006, 10:10 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