Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Joel Elliott   on Mar 10 In MS Office Category.

  
Question Answered By: Frederik Jones   on Mar 10

Try the following revised function  (and a sample sub to call it):

Sub AAAA()
Dim strList As String
strList$ = Chain(Range("A1:A5"))
MsgBox strList$
End Sub

Function Chain(TargetCells As Range, Optional CondOffset = 1, Optional
Separator = ";") As String
'TargetCells is the range  of cells with e-mail addresses
'CondOffset is the number of columns difference between the TargetCells and the
condition cells. B=1, C=2, etc.
Dim c As Range, TmpStr As String
For Each c In TargetCells
If LCase(c.Offset(0, CondOffset).Value) = "yes" Then
TmpStr$ = c.Value & Separator
Else
TmpStr$ = vbNullString
End If
Chain$ = Chain$ & TmpStr$
Next
End Function

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 


Tagged: