-8

I have data in below format

enter image description here

And Expecting output in below format

enter image description here

Community
  • 1
  • 1

1 Answers1

0

Using TEXTJOIN would be the easiest way, but if you wanted you can also use a VBA code.

Function Concat(rng As Range, Optional sep As String = " / ") As String
    Dim rngCell As Range
    Dim strResult As String
    For Each rngCell In rng
        If rngCell.Value <> "" Then
            strResult = strResult & sep & rngCell.Value
        End If
    Next rngCell
    If strResult <> "" Then
        strResult = Mid(strResult, Len(sep) + 1)
    End If
    Concat = strResult
End Function

In your case, you can use column F as a helper range and enter =Concat(A7:E7) in cell F2. This will generate the appropriate list back fitting your needs, minus the "-" between the EMP ID and the values. You can play around with the code to fix that if you desire, but this code will work for you.

William C.
  • 212
  • 1
  • 14