Reputation: 31
I have a program (Sub) in VBA (in Excel) that has an optional Boolean argument. The default is set to true. When I try to start the program with F8, it dings at me and does nothing. When I try to start it with F5, it brings up the program list (same as alt-F8 from within Excel itself). The program I'm trying to start is not in the list.
The relevant part of the code is just the first line:
Sub PopulateUniqueIngredientItems(Optional SortSheets As Boolean = True)
If I make argument required, it starts (but fails due to the missing argument).
Any ideas as to what am I doing wrong? Or, is it just not possible to start a Sub directly when it has a parameter?
Upvotes: 2
Views: 316
Reputation: 81
You can call it without args but from another sub:
Sub anotherSub()
Call PopulateUniqueIngredientItems
End Sub
Sub PopulateUniqueIngredientItems(Optional SortSheets As Boolean = True)
End Sub
Upvotes: 2