引数が可変(ParamArray)
日曜日, 7月 21st, 2019Function jointText(ParamArray 範囲())
Dim i As Long
Dim cell As Range
Const 区切り文字 As String = "-"
For i = 0 To UBound(範囲)
If 範囲(i).Count > 1 Then
For Each cell In 範囲(i)
jointText = jointText & 区切り文字 & cell
Next cell
Else
jointText = jointText & 区切り文字 & 範囲(i) '2個目以降
End If
Next i
jointText = Right(jointText, Len(jointText) - Len(区切り文字))
End Function
※省略可能なOptionalは使えない