title: How to detect when optional ByRef parameter was not passed
body: <p>I'm trying to detect whether an opational parameter was passed but for some reason all the usual functions (IsMissing()/IsEmpty()/IsNull()) always return false.</p>
  
  <p>This is what I'm trying:</p>
  
  <pre><code>Public Sub SetValue(Key As String, Optional ByRef ws As Worksheet)
      If IsMissing(ws) Or IsEmpty(ws) Or IsNull(ws) Then
          ws = ThisWorkbook.Sheets(SheetName)
      End If
  </code></pre>
  
  <p>I also tried setting the ws to Nothing or Null but the result was the same:</p>
  
  <pre><code>Public Sub SetValue(Key As String, Optional ByRef ws As Worksheet = Nothing)
      If IsMissing(ws) Or IsEmpty(ws) Or IsNull(ws) Then
          ws = ThisWorkbook.Sheets(SheetName)
      End If
  </code></pre>
  
  <p>Any idea why this might be happenning?</p>