我有以下代码,使用col范围作为值搜索工作表中的列。而不是那样,我需要使用col名称(在该表中)作为搜索条件并执行相同的功能。
我尝试了另外一种方法来解决这个问题,并且我遇到了语法错误。
原始代码:
Sub WBR()
Dim Count1Criteria As Variant
Dim Count3Criteria As Variant
Dim test As Variant
Dim wf As WorksheetFunction
Set wf = Application.WorksheetFunction
Filter3InSummary = Array(Array("AE43", "TT", "I:I", "<>Duplicate TT", _
"G:G", "<>Not Tested", _
"U:U", "Item"))
For Each test In Filter3InSummary
With Worksheets(test(1))
Range(test(0)) = wf.CountIfs(.Range(test(2)), test(3), _
.Range(test(4)), test(5), _
.Range(test(6)), test(7))
End With
Next
代码我在哪里&#39; M获取语法错误:
Sub WBR()
Dim Count1Criteria As Variant
Dim Count3Criteria As Variant
Dim test As Variant
Dim wf As WorksheetFunction
Set wf = Application.WorksheetFunction
Filter3InSummary = Array(Array("AE43", "TT", "Cname1", "<>Duplicate TT", _
"Cname2", "<>Not Tested", _
"Cname3", "Item"))
For Each test In Filter3InSummary
With Worksheets(test(1))
Range(test(0)) = wf.CountIfs(.rows(1).Find(test(2),lookat:xlWhole).EntireColumn), test(3), _ .rows(1).Find(test(2),lookat:xlWhole).EntireColumn), test(5), _ .rows(1).Find(test(2),lookat:xlWhole).EntireColumn), test(7))
答案 0 :(得分:0)
在每个EntireColumn
之后你有额外的右括号,你错过了每个命名参数的等号。
Range(test(0)) = _
wf.CountIfs( _
.Rows(1).Find(test(2), lookat:=xlWhole).EntireColumn, test(3), _
.Rows(1).Find(test(2), lookat:=xlWhole).EntireColumn, test(5), _
.Rows(1).Find(test(2), lookat:=xlWhole).EntireColumn, test(7))