I have a function that I want to call from a variety of modules. Whats the best way to do this in VB (excel).
module "SheetExists"
Function Name(SheetName As String) As Boolean
' returns TRUE if the sheet exists in the active workbook
SheetExists = False
On Error GoTo NoSuchSheet
If Len(Sheets(SheetName).Name) > 0 Then
SheetExists = True
Exit Function
End If
NoSuchSheet:
End Function
module "Main"
If Not SheetExists.Name("mySheet") Then
'do this
Else
' else do this
End If
I DONT want to have to do this or do I??
Call SheetExists.Name("mySheet")
Is that the only way to call a function from another module? Do I have to declare it as a Public function or something?