title: Function Issue: Date filter in Excel VBA
body: <p>So, I'm having an issue with making a function that just returns 1 if the date is set in a quarter previous to the actual one. I'm not fluent with functions, so it might be a stupid mistake, but I can't fix it. Thank you kind souls:)</p>
  
  <pre><code>Public Function IsOnQX(ByVal InputCell As Range, ByVal Month As Long) As Integer
      Dim ActualQuarter As String
      Dim PastQuarter As String
  
          If (Month &lt; 1) Or (Month &gt; 12) Then
                  Call Err.Raise(6) ' Value out of Bounds '
          End If
  
          Set ActualQuarter = ((Month(Now())) + 2) \ 3
          Set PastQuarter = ((Month(InputCell.Value)) + 2) / 3
  
          If (InputCell.Value = "") Or (PastQuarter &lt; ActualQuarter) Then
              IsOnQX = 1
          Else
              IsOnQX = 0
          End If
  
  End Function
  </code></pre>
  
  <p>My idea is to use this function as part of a COUNTIFS statement in a Macro that returns the number of items that comply with two conditions: either the cell in the table is empty (returns 1) or the date contained in said cell is from a previous quarter period (=1) again, and just count the 1s to get the total amount. </p>
  
  <p>Something like;</p>
  
  <pre><code>Range("C63")=COUNTIFS(TablaI_R[Project Name], IF(ISNUMBER(SEARCH(TablaI_R[Project Name],AZAR),1,0)=1), TablaI_R[Actual Closed Date], IF(IsOnQX(TablaI_R[Actual Closed Date])=1, 1, 0)=1)
  </code></pre>
  
  <p>Thanks everyone!</p>