我想在「Total Service Fees」單元格上面得到列G:26到1的總和。我遇到運行時錯誤'1004'。應用程序定義或對象定義的錯誤。有誰知道這可能來自什麼?ActiveCell.Formula運行時錯誤1004
Worksheets(1).Select
Dim rng1 As Range
Dim strSearch As String
strSearch = "Total Service Fees"
Set rng1 = Range("F15:F100").Find(strSearch, , xlValues, xlWhole)
If Not rng1 Is Nothing Then
rng1.Offset(0, 1).Select
ActiveCell.Formula = "=SUM(G26:" & ActiveCell.Offset(-1, 0).Select & ")"
Else
MsgBox strSearch & " not found"
End If
我得到正確的答案,但我仍然得到這個錯誤。
我不打算在該公式中使用「選擇」方法。詳細說明:打開立即窗口(CTRL + G)並輸入 - 包括'?',然後按回車:??= SUM(G26:「&ActiveCell.Offset(-1,0).Select& )「'你應該看到這不是一個有效的公式。 – Gaffi 2013-04-29 19:42:27
你會建議什麼?它給我= SUM(G26:True) – Sokies 2013-04-29 19:45:01
''SUM(G26:True)'是你告訴代碼分配公式的代碼。這是無效的,所以你需要提供一個有效的'A1'風格範圍標識符。 – Gaffi 2013-04-29 19:48:03