我有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