我有兴趣让rng
仅选择偶数列(在第12列至9999之间)。我在下面附加了我的代码。请协助,谢谢!
Sub calDailyGC()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Set w = Application.WorksheetFunction
Dim gc As Double
numGC = Cells(46, 7).Value
numDays = Cells(47, 7).Value
For k = 3 To numDays + 1
Rng = Range(Cells(k, 12), Cells(k, 9999))
sumRate = 0
For j = 1 To numGC
gc = Application.WorksheetFunction.Large(Rng, j)
Debug.Print gc
sumRate = sumRate + gc
Next j
Next k
avgGCRate = sumRate / numGC
End Sub
答案 0 :(得分:1)
尝试使用此方法代替Rng = Range(Cells(k, 12), Cells(k, 9999))
:
With ThisWorkbook.ActiveSheet
Dim Rng As Range
Dim i As Long
i = 12
Set Rng = .Cells(k, i)
i = i + 2
Do While i < 9999
Set Rng = Union(Rng, .Cells(k, i))
i = i + 2
Loop
End With