我对 VBA 很陌生,所以我确定我所缺少的非常简单,并且有更多经验的人不会忽视。
我的代码如下:
Sub test_match()
Sheets("Course Cascade").Select
Dim i As Long
Dim r As Long
Dim c As Long
Dim rfirst As Long
Dim cfirst As Long
Dim rlast As Long
Dim colnum As Long
Dim rownum As Long
Dim csum As Long
Dim rowTerm As Long
Dim k As Integer
Dim rabove As Long
Dim ccount As Long
Dim clkup As Long
r = 107: c = 7: rowTerm = 106: ccount = 3: cfirst = 7: csum = c - 1: k = WorksheetFunction.CountIf(Range("e107:e1661"), ">0"): clkup = 5
If Cells(r, ccount) <= WorksheetFunction.SumProduct((Range(Cells(47, c), Cells(74, c))), (--Range("CourseCascadeRow").Value = Cells(r, clkup))) Then
Cells(r, c) = WorksheetFunction.IfError(WorksheetFunction.Index("CourseCascadeCt", WorksheetFunction.Match(Range(Cells(r, 5)), Range("CourseCascadeCtRow"), 0), _
WorksheetFunction.Match(Range(Cells(106, c)), Range("CourseCascadeCol"), 0) / WorksheetFunction.Index("CourseCascadeCt", WorksheetFunction.Match(Range(Cells(r, 5)), Range("CourseCascadeCtRow"), 0), _
WorksheetFunction.Match(Range(Cells(106, c)), Range("CourseCascadeCol"), 0))), 0)
那里也有一个 else 参数,但我已经将类型不匹配错误隔离到 Sumproduct 公式的这一部分: --Range("CourseCascadeRow").Value = Cells(r, clkup))) 。范围末尾的“.value”是我尝试添加和删除的东西,没有任何变化。
谁能告诉我我做错了什么?我知道代码很丑...
谢谢!