【发布时间】:2017-08-03 16:35:20
【问题描述】:
我正在尝试编写一个简单的 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
【问题讨论】: