汇编误差,未定义的子或功能



当前实现了我公司突出订单异常的项目,我写了此VBA代码,以比较订单状态和当前日期和订单日期之间的日期差异。日期如下所示:" 2019-05-06 3:11 pm"

当我影响宏到一个按钮并单击它时,我会遇到此错误:"编译错误,sub或dunction未定义",调试器光标指向" sub argears((" ...

我希望你能帮我!谢谢:(

这是我的代码:

Sub Problem()
Dim orderDate As Date
Dim difDate
Dim statusToUse As Range
Set statusToUse = Range("C2:C100")
Dim statusCell As Range
Dim a As String
a = "accepted"
Dim s As String
s = "shipped"
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim l As Integer
Dim m As Integer
Dim dateToUse As Range
Set dateToUse = Range("D2:D100")
Dim dateCell As Range
Dim currentDate As String
currentDate = Date
y = Split(Split(Range("A1").Value, ":")(1), "-")
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For Each statusCell In statusToUse.Areas
For Each dateCell In dateToUse.Areas
orderDate = DateValue(Join(Array(y(2), y(1), y(0)), "-"))
difDate = DateDiff("d", currentDate, orderDate)
If status = a And difDate <= 7 Then
status.Interior.ColorIndex = 46
i = i + 1
ElseIf status = a And difDate <= 2 Then
status.Interior.ColorIndex = 27
j = j + 1
ElseIf status = a And difDate > 7 Then
status.Interior.ColorIndex = 3
k = k + 1
ElseIf status = s Then
status.Interior.ColorIndex = 10
l = l + 1
Else
m = m + 1
End If
i = i - j
Next dateCell
Next statusCell
MsgBox "There are" + i + "risky orders"
End Sub

通常会发生此错误时,当子在工作表中而不是新模块中时。

如果已经在模块中,请检查模块的名称是否不同。

最新更新