我正在尝试动态设置范围。但是,我遇到了一些错误:
分配左侧的函数调用必须返回Variant或Object。
Sub calDailyGC()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Dim Rng As Range
numGC = Cells(46, 7).Value
numDays = Cells(47, 7).Value
Debug.Print numGC
Debug.Print numDays
For k = 3 To numDays + 1
Set Rng = Range(Cells(k, 12), Cells(k, 9999))
sumRate = 0
For j = 1 To numGC
rate = Application.WorksheetFunction.Large(Rng, j)
sumRate = sumRate + rate
Next j
avgGCRate = sumRate / numGC
Next k
Debug.Print avgGCRate
End Sub
答案 0 :(得分:2)
分配左侧的函数调用必须返回Variant或Object。
rate = Application.WorksheetFunction.Large(Rng,j)
请勿使用Rate
。这是VBA中的保留字。您可以阅读有关Rate
here
更改为说
LargeVal = Application.WorksheetFunction.Large(Rng, j)