我的程式碼如下:
Dim i, j, n, m As Integer
Dim V5, V10, V20, V60, V120, V240 As Double
Dim R5, R10, R20, R60, R120, R240 As Range
n = Sheets("成交量").Cells(Rows.Count, 3).End(xlUp).Row
m = Sheets("成交量").Cells(11, Columns.Count).End(xlToLeft).Column
For i = 12 To n
Sheets("得分").Cells(i, 1) = Sheets("成交量").Cells(i, 1)
Sheets("得分").Cells(i, 2) = Sheets("成交量").Cells(i, 2)
Sheets("得分").Cells(i, 3) = Sheets("成交量").Cells(i, 3)
V = Sheets("成交量").Cells(i, m)
Set R5 = Sheets("成交量").Range(Cells(i, m - 4), Cells(i, m))
Sheets("得分").Range("B1") = WorksheetFunction.Max(R5)
If V = WorksheetFunction.Max(Sheets("成交量").Range(Cells(i, m - 4), _
Cells(i, m))) Then
Sheets("得分").Cells(i, 6) = 1
End If
Next
執行後出現
執行階段錯誤'1004':
應用程式或物件定義上的錯誤
有問題的是 "Set R5 = Sheets("成交量").Range(Cells(i, m - 4), Cells(i, m))"
這一列,我不知道這一列程式碼有什麼問題,請教大家幫我解惑,謝謝