bloodmilksky
08-17-2017, 06:10 AM
Hi Guys I was just wondering if anyone can help with the below. I have put in AndEvaluate Worksheet Function to check that range D21 has one of the following values "FULL","AM","PM" in it before progressing with the rest of the code. However when I have tried this after numerous adjustments and changes it keeps on coming up with a compile Syntax error :(
I was wondering if anyone can help please
Option Explicit
Sub TooManyHolidays()
Dim msg As String
Dim Ans As VbMsgBoxResult
If Sheets("Request Form").Range("B14") < 26 And Sheets("Request Form").Range("E21") < 10 Then AndEvaluate(WorksheetFunction.If(Sheets("Request Form").Range("FORM3"), "FULL" Or "AM Or "PM") <> 1 Then
NewBookingCheck.NewBookingCheck
ElseIf Sheets("Request Form").Range("B14") >= 26 Then
msg = (" You Dont Have Enough Holiday! Would You Like To Continue? ")
Ans = MsgBox(msg, vbYesNo)
If Ans = vbNo Then
Sheets("Request Form").Select
Range("Employee3").ClearContents
Range("DateRequest").ClearContents
Application.DisplayAlerts = False
ThisWorkbook.Save
Application.DisplayAlerts = True
WorkbookClose
End If
If Ans = vbYes Then
Sheets("Request Form").Select
Range("Employee3").ClearContents
Range("DateRequest").ClearContents
Range("Employee3") = Application.UserName
ElseIf Sheets("Request Form").Range("E21") >= 11 Then
msg = (" You Cant Book More Than 10 Days In One Request! Would You Like To Continue? ")
Ans = MsgBox(msg, vbYesNo)
If Ans = vbNo Then
Sheets("Request Form").Select
Range("Employee3").ClearContents
Range("DateRequest").ClearContents
Application.DisplayAlerts = False
ThisWorkbook.Save
Application.DisplayAlerts = True
WorkbookClose
End If
If Ans = vbYes Then
Sheets("Request Form").Select
Range("Employee3").ClearContents
Range("DateRequest").ClearContents
Range("Employee3") = Application.UserName
End If
ElseIf Evaluate(WorksheetFunction.IfError(Sheets("Request Form").Range("FORM3"), "Full" Or "Am" Or "Pm")) <> 0 Then
msg = ("Please Enter A Day Type!")
Ans = vbOK
End If
End If
End Sub
I was wondering if anyone can help please
Option Explicit
Sub TooManyHolidays()
Dim msg As String
Dim Ans As VbMsgBoxResult
If Sheets("Request Form").Range("B14") < 26 And Sheets("Request Form").Range("E21") < 10 Then AndEvaluate(WorksheetFunction.If(Sheets("Request Form").Range("FORM3"), "FULL" Or "AM Or "PM") <> 1 Then
NewBookingCheck.NewBookingCheck
ElseIf Sheets("Request Form").Range("B14") >= 26 Then
msg = (" You Dont Have Enough Holiday! Would You Like To Continue? ")
Ans = MsgBox(msg, vbYesNo)
If Ans = vbNo Then
Sheets("Request Form").Select
Range("Employee3").ClearContents
Range("DateRequest").ClearContents
Application.DisplayAlerts = False
ThisWorkbook.Save
Application.DisplayAlerts = True
WorkbookClose
End If
If Ans = vbYes Then
Sheets("Request Form").Select
Range("Employee3").ClearContents
Range("DateRequest").ClearContents
Range("Employee3") = Application.UserName
ElseIf Sheets("Request Form").Range("E21") >= 11 Then
msg = (" You Cant Book More Than 10 Days In One Request! Would You Like To Continue? ")
Ans = MsgBox(msg, vbYesNo)
If Ans = vbNo Then
Sheets("Request Form").Select
Range("Employee3").ClearContents
Range("DateRequest").ClearContents
Application.DisplayAlerts = False
ThisWorkbook.Save
Application.DisplayAlerts = True
WorkbookClose
End If
If Ans = vbYes Then
Sheets("Request Form").Select
Range("Employee3").ClearContents
Range("DateRequest").ClearContents
Range("Employee3") = Application.UserName
End If
ElseIf Evaluate(WorksheetFunction.IfError(Sheets("Request Form").Range("FORM3"), "Full" Or "Am" Or "Pm")) <> 0 Then
msg = ("Please Enter A Day Type!")
Ans = vbOK
End If
End If
End Sub