自定义模拟textjoin函数

时间:2026-02-12 18:10:02

1、ALT+F11打开VBE编辑器;

2、插入>>模块,粘贴以下代码:

Function textjoin(合并符, tf, texts)


Application.Volatile True
On Error GoTo xxx
Dim arr, a As String, pp As String
pp = Join(WorksheetFunction.Transpose(texts), "-")
arr = WorksheetFunction.Transpose(texts)
GoTo yyy
xxx:
arr = WorksheetFunction.Transpose(WorksheetFunction.Transpose(texts))
yyy:
If tf = 1 Then
For i = 1 To UBound(arr)
If arr(i) = "" Then arr(i) = "#$%"
Next
arr = Filter(arr, "#$%", False)
End If
textjoin = Join(arr, 合并符)
End Function

3、保存文件为.xlsm格式。


© 2026 途途旅游
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com