|
各位大侠帮帮忙:同时满足条件1和条件2,如何把对应的单元格合并到新的单元格,详细见附件
之前有个大侠帮我做了这个自定义函数,应该如何修改下代码满足以上的要求?
Option ExplicitFunction hbxm(r As Range, d As Range, Optional z = 1) Dim arr As Variant, n As Integer Dim i As Integer, str As String str = d.Value arr = r.Value If r.Columns.Count > 2 Then Exit Function For i = 1 To UBound(arr) If arr(i, 1) = str Then If n = 0 Then n = n + 1 hbxm = arr(i, 2) Else If z = 1 Then hbxm = hbxm & " " & arr(i, 2) Else hbxm = hbxm & " " & Right$(arr(i, 2), 2) End If End If NextEnd Function
附件.rar
(12.25 KB, 下载次数: 151)
|
|