2
我在這段代碼中有一些問題,我的.Value
不起作用。'For'循環中的平均值
一切工作正常,如果我做了我的硬編碼 - >>> .value的=「=平均(E2:E7)」
然而,當我做下面的下面,它不會工作。我敢肯定它是 - >範圍( 「E」 ........)
'Iterate average for close price per week
Dim startOfWeek As Integer
Dim endOfWeek As Integer
numberOfWeek = 52
startOfWeek = 2
endOfWeek = 6
secondRow = 2
For i = 1 To numberOfWeek
range("J" + CStr(secondRow)).Select
With Selection
.Value = "=Average(" + range("E" + CStr(startOfWeek) + ":E" + CStr(endOfWeek)).Select + ")"
.Font.Bold = False
End With
secondRow = secondRow + 1
startOfWeek = startOfWeek + 5
endOfWeek = endOfWeek + 5
Next i
感謝但它是在紅色和錯誤「預期:語句結束」 –
哦,我已經認識到存在丟失「 &「。 –
.Value =「= Average(E」&CStr(startOfWeek)&「:E」&CStr(endOfWeek)&「)」 –