本文为《别怕,Excel VBA其实很简单(第3版)》随书问题参考答案
Function JoinText(Rng As Range, Optional Txt As String = ",") As String
Dim c As Range
For Each c In Rng
JoinText = JoinText & c.Value & Txt
Next c
JoinText = Left(JoinText, Len(JoinText) - 1)
End Function
或者
Function JoinText(Rng As Range, Optional Txt As Variant) As String
Dim c As Range
If IsMissing(Txt) Then Txt = ","
For Each c In Rng
JoinText = JoinText & c.Value & Txt
Next c
JoinText = Left(JoinText, Len(JoinText) - 1)
End Function
声明:本站所有文章均出自互联网,只为学习之用;如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)