我有3个If语句,无论“dept”的值如何,总是会导致错误。
如果我删除两个If语句,只剩下一个,它就可以工作。我究竟做错了什么?多个VBA如果或者陈述
Dim Dept As String
Dim wb As Workbook
Set wb = ThisWorkbook
Dept = Application.WorksheetFunction.VLookup(Name, Sheet1.Range("F10"), 1)
If Dept = "Dept1" Or "Dept2" Then
wb.SendMail "email address", Subject:="Subject heading 1"
End If
If Dept = "Dept3" Or "Dept4" Then
wb.SendMail "email address", Subject:="Subject heading 2"
End If
If Dept = "Dept5" Or "Dept6" Then
wb.SendMail "email address", Subject:="Subject heading 3"
End If
我已经编程了20年以上,刚刚从你那里学到了一些新的东西'Application.WorksheetFunction.VLookup(...'。不知道内置的公式函数是可用的像那谢谢! – DarrenMB 2014-09-25 15:08:31