我正在尝试在VBA代码中的变量内创建公式。 当代码来创建邮件部分时,它会获得CRASH。
numer
出了什么问题?
Dim numer As Integer
Dim day As Integer
day = WorksheetFunction.TODAY()
numer = WorksheetFunction.WeekNum(day, 1)
With OutMail
.Subject = "text text" & CStr(numer) & " text text"
答案 0 :(得分:2)
VBA不允许使用TODAY()函数。请改用日期功能。此外,整数只能保存最多32,767的值。请改用long。
Private Sub this()
Dim numer As Integer
Dim day As Long
day = Date
numer = WorksheetFunction.WeekNum(day, 1)