1
我正在嘗試編寫一個簡單的VBA宏,它將採用活動單元格的列和用戶的輸入將一行單元格範圍添加到一起。範圍是通過將用戶輸入的整數添加到活動列並且是結束列來計算的。問題是,當我運行它時,它給了我一個「編譯錯誤:無效的限定符」,並在'總'行中生氣。VBA宏編譯錯誤
這是我的代碼。我剛剛開始使用VBA,但不能那麼辛苦......對吧?
Sub Food()
Dim first As Variant
Dim last As Integer
Dim days As Integer
Dim month As Range
Dim total As Double
first = ActiveCell.Column
days = InputBox("Days in the month?")
last = first + days
Set month.Value = Range(Cells(first, 4), Cells(last, 4))
total.Value = WorksheetFunction.Sum(month)
Worksheets(1).Cells(1, 13).Value = total
End Sub