title: SumIf using dates and ranges in VBA
body: <p>I am trying to sum a row biased on the fact that another row has the same month as a variable that is defined by the user. I believe the sumif function would be my best bet but it doesn't seem to be working for me. The row I want it to look at obviously is a row of Date with date formatting (used .numberformat = "ddd mm/dd") but the sumif doesn't seem to be able to pick out the month in each cell. Here is the code I have so far:</p>
  
  <pre><code>Dim cMade As Integer
  Dim sDate As Date
   cMade = cMade + Application.WorksheetFunction.SumIf(ActiveSheet.Range("B1:RC1"), Month(sDate), ActiveSheet.Range("B30:RC30"))
  </code></pre>
  
  <p>As you can see sDate is the date that the user imputs via userform then i convert that using dateserial. and B1-RC1 are the dates i want it to look at. And Range B30-RC30 are the sums i want it to grab if the months match up (the reason I have it as + cMade is because it is in a loop that loops through sheets).</p>
  
  <p>Is this code correct? I have been messing with it and looking for alternatives for hours but I cant not seem to come up with anything! </p>