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