The following code snippet works. The optional parameter p3 can be "ON", "OFF", or omitted (missing).
Public Function Temp(p1, p2, Optional p3 As Variant) As Variant
. . .
If Not IsMissing(p3) Then
Select Case UCase(pErrMsgSw)
Case "ON": ErrMsgSw = True
Case "OFF": ErrMsgSw =...