Concatenate with Separators and Quotes with Exclude !
A small revision to the ConcSep function where
- the opening quote can be different from the closing quote
- some values can be excluded from the quotes (used when the cell value is a function like to_date)
So here goes ConcSepQuote_Excl :
Public Function ConcSepQuote_Excl(InCells As Range, _
Quot_St As String, Quot_End As String, _
Sep As String, Excl As String) As String
Dim OutStr As String
Dim Cell As Variant
OutStr = “”
If InCells Is Nothing Then Exit Function
On Error Resume Next
For Each Cell In InCells
If InStr(1, Cell.Value, Excl, vbTextCompare) > 0 Then
OutStr = OutStr & Cell.Value & Sep
Else
OutStr = OutStr & Quot_St & Cell.Value & Quot_End & Sep
End If
Next Cell
OutStr = Left(OutStr, Len(OutStr) - Len(Sep))
ConcSepQuote_Excl = OutStr
and the revised example :
