Jason Campbell
Board Regular
- Joined
- Mar 22, 2016
- Messages
- 77
Dear all,
Really new to VBA and trying to use the workday function to calculate the stipulated days (including bankholidays named range) to give me the final 'Due date' for a initial 'Statement of Need' received date.
I keep getting a Compile error:'Statement invalid outside Type block'
my VBA code is as follows:
Sub DateTest()
Dim SonDate As Date
Dim DueDate As Date
Dim Sent Date As Date
wf As WorksheetFunction
Set wf = Application.Worksheetfunction
SonDate = Range("A2").Value
DueDate = wf.WorkDay("A2", 15, bankholidays)
SentDate = Range("C2").Value
If SentDate > DueDate Then
MsgBox "Due date exceeded! Due date was " & DueDate
ElseIf SentDate <= DueDate Then
MsgBox "Response sent within appropriate time frame."
End If
End Sub
Any pointers/assistance you could give would be welcomed. I'm a VBA virgin, so please explain in simple terms
Many thank,
Jason
Really new to VBA and trying to use the workday function to calculate the stipulated days (including bankholidays named range) to give me the final 'Due date' for a initial 'Statement of Need' received date.
I keep getting a Compile error:'Statement invalid outside Type block'
my VBA code is as follows:
Sub DateTest()
Dim SonDate As Date
Dim DueDate As Date
Dim Sent Date As Date
wf As WorksheetFunction
Set wf = Application.Worksheetfunction
SonDate = Range("A2").Value
DueDate = wf.WorkDay("A2", 15, bankholidays)
SentDate = Range("C2").Value
If SentDate > DueDate Then
MsgBox "Due date exceeded! Due date was " & DueDate
ElseIf SentDate <= DueDate Then
MsgBox "Response sent within appropriate time frame."
End If
End Sub
Any pointers/assistance you could give would be welcomed. I'm a VBA virgin, so please explain in simple terms
Many thank,
Jason