Returning multiple text data into 1 column from many column entrie

R

Roger

Hi.
I have a large worksheet that contains records of avtivities from record 3
and onwards with logic link predecessors to other activities in columns E
through IT.

I want Excel to identify where there is a logical link represented by an
Integer number in columns E though IT and return the cell data into column D
record by record as indicated below.
Where there is more than 1 entries in columns E through IT the returned data
in column D needs to be separated by a comma.
Preferrably I would like to avoid having a comma at the end if possible.

I would appreciate if someone could give me some help on this issue.

D E F G H

2,3,4 2 3 4
2 2
3,4 3 4
1,3 1 3
4 4
 
J

Jarek Kujawa

you might use this UDF. Press ALT+F11 to go to VBA, then click Insert-
Module and copy/paste this code.
then go to D1 and insert: =link(D1)


Function link(cel As Range) As String
Dim counter As Integer

For Each cell In Range("E" & cel.Row & ":IT" & cel.Row).Cells
If Len(cell.Value) Then
counter = counter + 1
If counter > 1 Then
tekst = tekst & "," & cell.Value
ElseIf counter = 1 Then
tekst = cell.Value
End If
End If
Next cell

link = tekst

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top