Function arguments
Posted by Stuart Walker on June 18, 2001 7:31 AM
Hi,
I'm fairly new to Excel (2000) VBA and am running into a problem with a fairly simple Function. In the sample funtion listed below :
Function WhatsForLunch(WeekDay As String, Hour _
As Integer) As String
' Returns a lunch menu based on the day and time.
If WeekDay = "Friday" Then
WhatsForLunch = "Fish"
Else
WhatsForLunch = "Chicken"
End If
If Hour > 4 Then WhatsForLunch = "Too late"
End Function
When I create the sub,
Private Sub CommandButton1_Click()
WhatsForLunch("Friday", 3)
End Sub
Excel tells me I have a syntax error and will not compile. Can anyone tell me why this is happening ?
Thanks,
Stuart.