title: How to check if Variant is empty and assign other variable to it in Excel VBA
body: <p>I am trying to make a function that has 3 inputs, were two of them are optional: <code>colOffsetA</code> &amp; <code>colOffsetB</code>. If only one of the two optional ones is used in the function, then I wish that this value is automatically assigned to the empty one as well. Right now the code assigns the value 0 for <code>colOffsetB</code> for some reason.</p>
  
  <pre><code>Function TestCode(cellA As Range, Optional colOffsetA As Variant, Optional colOffsetB As Variant) As String
  
      If IsEmpty(colOffsetB) Then
          colOffsetB = colOffsetA
      End If
  </code></pre>