標題:
[發問]
請問countifs多條件,如何用VBA呢?會跑到盪掉
[打印本頁]
作者:
starry1314
時間:
2015-8-7 23:55
標題:
請問countifs多條件,如何用VBA呢?會跑到盪掉
函數:=COUNTIFS($A$3:$A$16,"<>*T*",$A$3:$A$16,"<>*Q*",$A$3:$A$16,"<>*I*",$A$3:$A$16,"<>*P*",$A$3:$A$16,"<>*L*",$B$3:$B$16,F2,$C$3:$C$16,"=2")
[attach]21666[/attach][attach]21667[/attach]
作者:
Scott090
時間:
2015-8-9 10:37
回復
1#
starry1314
資料多,試用這個
Option Base 1
Option Explicit
Sub 菜色計算()
Dim i&, j%, k%
Dim aa '區域、菜色、數量 資料
Dim bb ''菜色
Dim cc$ '區分條件
Dim dd '搜尋結果
Sheets("工作表1").Activate
aa = Range("A3:C" & [A2].End(xlDown).Row)
bb = Range("F2:F" & [F2].End(xlDown).Row)
Range("G2:G" & UBound(bb) + 1).Clear '第2列開始菜色區分
ReDim dd(UBound(bb), 1)
cc = "TQILP"
For i = 1 To UBound(aa)
If InStr(cc, Mid(aa(i, 1), 2, 1)) = 0 And aa(i, 3) = 2 Then
For j = 1 To UBound(bb)
If aa(i, 2) = bb(j, 1) Then dd(j, 1) = dd(j, 1) + 1: Exit For
Next
End If
Next i
Cells(2, "G").Resize(UBound(dd)) = dd
End Sub
複製代碼
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)