更新时间:2023-11-07 18:30:22
您可以使用 Join()
函数使用定界符将一维数组的所有元素连接在一起.
You can use the Join()
function to join all the elements of a 1 dimensional array with a delimiter.
下面使用 Transpose()
函数形成维数组(此方法适用于单列或单行).
The Transpose()
function is used below to form the dimensional array (this approach works on a single column or row).
Sub Main()
Dim arr
arr = Join(Application.Transpose(Range("A2:A5").Value), ",")
MsgBox arr
End Sub
或作为UDF
Public Function Merge(r As Range) As String
Merge = Join(Application.Transpose(r.Value), ",")
End Function