我开始为 excel 2007 学习 VBA。任何人都可以帮助解释为什么在执行时会发生此错误:
代码是
Public Sub LastVariable_Check()
'Check if Last Variable is of latest month sales
'lastvariable = lv
lv = wkbOut.Sheets("Sheet1").Range("B1",Range("B1").End(xlToRight)).End(xlToRight).Text
If "0" & Mid(lv, InStr(lv, "Month/") + 6, 1) = strmth _
And Mid(lv, InStr(lv, "Month/") + 8, 4) = strYear Then
Set wkbRaw = Workbooks.Open(strInputQCPath & "Errorlog.xlsx")
wkbRaw.Sheets("Sheet1").Range("A1").Offset(i, 2).Value = "Correct"
wkbRaw.SaveAs Filename:=strInputQCPath & "Errorlog.xlsx"
wkbRaw.Close
Else
Set wkbRaw = Workbooks.Open(strInputQCPath & "Errorlog.xlsx")
wkbRaw.Sheets("Sheet1").Range("A1").Offset(i, 2).Value = "Incorrect"
wkbRaw.SaveAs Filename:=strInputQCPath & "Errorlog.xlsx"
wkbRaw.Close
End If
End Sub
请帮忙
谢谢!