In the data available in attachment, i am trying to extract starting 3 letters of each cell value and add only UNIQUE values with ',' separator.
I tried to find logic with below code but i know it fails.
Can anyone please help me to correct it or provide fresh code to achieve the intent.
Output required is as shown in the attachment.
Just in order to get best possible solution, this querry is cross posted @
Option Explicit Sub extractpC() Dim pc As String Dim pc1 As String Dim pcDiv1 As String Dim cell As Range pc1 = "" For Each cell In ActiveSheet.Range("A2", ActiveSheet.Cells(Rows.Count, "A").End(xlUp)) pc = Left(cell.Value, 3) 'MsgBox pc If pc1 = "" Then pc1 = pc ElseIf pc = pc1 Then pcDiv1 = pc1 Else: pcDiv1 = pc & "," & pc1 End If ' pcDiv1 = pcDiv1 + pcDiv1 End If Next cell MsgBox pcDiv1 End Sub