Function
SelParticipants(Condition, SearchArea
As
Range,
Optional
Selector = 1,
Optional
Delimiter
As
String
=
", "
)
As
String
Dim
c
As
Range, cl
As
Long
, ret
As
String
, maxrow
As
Long
With
SearchArea.Parent
maxrow = .Cells(.Rows.Count, SearchArea.Column).
End
(xlUp).Row
End
With
For
Each
c
In
SearchArea.Rows(1).Cells
If
c = Condition
Then
cl = c.Column
Exit
For
End
If
Next
c
If
cl > 0
Then
For
Each
c
In
SearchArea.Columns(1).Cells
If
c.Row > SearchArea.Row
And
c <>
""
And
c.Offset(0, cl - SearchArea.Column) = Selector
Then
ret = ret & c.Text & Delimiter
End
If
If
c.Row > maxrow
Then
Exit
For
Next
c
End
If
If
Len(ret) > 0
Then
ret = Left(ret, Len(ret) - Len(Delimiter))
SelParticipants = ret
End
Function