Reputation: 3682
I am using VBA for Microsoft Excel 2007. My code is as follows:
Sub First()
End Sub
Function Two() As Boolean
End Function
Sub Sun()
If (Two()) Then
First()
End If
End Sub
What is wrong with this code? Why does it not compile?
Can I not use subs in IF
statements? Is it a magic of VBA? How can or should I resolve this issue?
Upvotes: 1
Views: 296
Reputation: 17574
Try removing the parenthesis from the call to First
.
Sub First()
End Sub
Function Two() As Boolean
End Function
Sub Sun()
If (Two()) Then
First
End If
End Sub
Upvotes: 3
Reputation: 10588
This compiles:
Sub First()
End Sub
Function Two() As Boolean
End Function
Sub Sun()
If (Two()) Then
First
End If
End Sub
You need to remove the parentheses from your First
call.
Upvotes: 0