Results 1 to 6 of 6

Concatenate values in different columns

Threaded View

  1. #1
    Registered User
    Join Date
    09-19-2013
    Location
    VA
    MS-Off Ver
    Excel 2003
    Posts
    2

    Concatenate values in different columns

    Hi,

    I am completely new to this forum. Not sure if I am doing this correct.

    I have a column (Column 5) which contain cells with strings separated by commas (example: Cell 2: F1, F2, F3, Cell 3: F4, F5, F6 etc). I am trying to find mistakes or duplicate values in these cells.

    I took these cells (strings) and separated them in columns and using conditional formatting, It can highlight duplicate strings (if any) in red.

    Next, I was trying to concatenate all these columns into the original cell by keeping the format (highlighted color) so the user can see what's has been duplicated.

    When I concatenate, the format is lost. I am stuck looking for an answer on this.

    I have this so far but the color is not being transfer when performing the macro:

    Sub ConcatenateRefDesCol()
    Dim result As String
        Dim separator As String
        Dim Temp   As String
        
        separator = ","
        Last_Row = Sheets("Sheet1").Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Row
        For j = 2 To Last_Row
            Last_Column = Cells(j, ActiveSheet.Columns.Count).End(xlToLeft).Column
            If Last_Column <> 1 Then
                For i = 1 To Last_Column
                    
                    If i <> Last_Column Then
                        Temp = Cells(j, i).Value
                        result = result & Temp & separator & " "
                    Else
                        Temp = Cells(j, i).Value
                        result = result & Temp
                    End If
                    
                Next i
                Range("E" & j).Value = result
                Range(Cells(j, 2), Cells(j, Last_Column)).Select
                Selection.ClearContents
                Temp = ""
                result = ""
                i = 0
            Else
            End If
        Next j
    End Sub






    ColumnWithCells.png
    Last edited by fjavier415; 02-16-2021 at 11:56 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Concatenate values in range if value in multiple columns is true
    By LGN in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-14-2020, 08:18 AM
  2. Concatenate values in columns based on headers
    By datacruncher99 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-12-2019, 03:25 PM
  3. Replies: 3
    Last Post: 07-28-2016, 01:47 AM
  4. [SOLVED] Concatenate data from cells by values from two columns
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-14-2016, 04:02 PM
  5. Copy Values from two columns and Paste them in one (Concatenate).
    By pipoliveira in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 07-08-2014, 11:12 AM
  6. Concatenate values from columns and deleting duplicates
    By RandomP in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-15-2011, 06:20 PM
  7. concatenate values two columns
    By matrixknow in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-21-2007, 08:52 AM

Tags for this Thread

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