...ing logging 4.0

はてなブログに移行しました。D言語の話とかいろいろ。

区切り文字指定が可能なセル文字列連結関数

Function join(r As Range, sep As String) As String
    
    Dim result As String
    
    Dim c As Range
    For Each c In r
        If c.Value <> "" Then
            result = result & c.Value & sep
        End If
    Next c
    
    If Len(result) = 0 Then
        join = ""
    Else
        join = Left(result, Len(result) - Len(sep))
    End If

End Function