同时满足条件1和条件2,把对应c列的姓名合并在g列中
各位大侠帮帮忙:同时满足条件1和条件2,如何把对应的单元格合并到新的单元格,详细见附件之前有个大侠帮我做了这个自定义函数,应该如何修改下代码满足以上的要求?
Option ExplicitFunction hbxm(r As Range, d As Range, Optional z = 1)Dim arr As Variant, n As IntegerDim i As Integer, str As Stringstr = d.Valuearr = r.ValueIf r.Columns.Count > 2 Then Exit FunctionFor 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 IfEnd IfNextEnd Function
有大虾经过看看吗 是这样吧?
谢谢啊,这样的思路很清晰,我修改了一下公式就符合我现在的需求了,如果能做成自定义函数更好 =MID(TEXTJOIN("、",1,IF((A$2:A$35=E3)*(B$2:B$35=F3),C$2:C$35,"")),LEN(F3)+2,99)
页:
[1]