看板 Visual_Basic 關於我們 聯絡資訊
我的程式碼如下: 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))" 這一列,我不知道這一列程式碼有什麼問題,請教大家幫我解惑,謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.227.132.77 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Visual_Basic/M.1689854722.A.AED.html
LPH66: Range 裡的 Cells 不能單獨呼叫, 仍然要用原來的語法串 07/21 18:42
LPH66: 同一張資料表 (同一個 Sheets) 的話可以在前面加 . 簡寫 07/21 18:42
LPH66: 就是變成 ###.Range(.Cells(###), .Cells(###)) 07/21 18:43
foreverkn: 請問###是指 Sheets("成交量")這樣嗎? 07/21 22:00
foreverkn: 再請問所謂用原來的語法串是什麼意思?我上面的寫法的問 07/21 22:02
foreverkn: 題在哪裡? 07/21 22:03
foreverkn: 剛想了一下,我懂你的意思了 07/22 00:01
ideo: 非常感謝樓上的回答 07/22 22:13
MOONRAKER: 是敘述(statement),不是語法(syntax) 07/23 15:55
MOONRAKER: 全世界應該只有台灣人用後者矇混前者 還覺得很高級 07/23 15:56
diabolica: 推樓上 07/29 11:42
LPH66: 大概是我積非成是了吧 (用習慣了就這樣一直用了) 07/29 15:23
MOONRAKER: 永不嫌遲 有發現就可改 :) 07/30 08:56