title: Count with multiple variants
body: <p>I have used Variants in the past for something similar, but it was one dimensional in its solution.  I am wondering if utilizing Variants with two dimensions would be feasible.</p>
  
  <p><a href="https://i.stack.imgur.com/87a9E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/87a9E.png" alt="Img1"></a></p>
  
  <p>I have ever changing list of dates that correspond with a week, that will be entered in chronologically.  The next column is the count of that week.  <code>Column C</code> is the building that it took place in.</p>
  
  <p>For example, the first row shown in the image above takes place the week of <code>"10/2/2016"</code> and there was a count of 8 that week  which means the buildings in rows <code>2-9</code> are correlated with that week, and it continues on for each corresponding week.</p>
  
  <p>I have the sum of the counts for each year, so for the chart in <code>"E1:G14"</code>, I want to count each time the building is counted for each year, respectively.  I am just confused as to how to approach it and if Variants would be useful or if using a <code>CountIfs</code> for the ranges would work best.</p>
  
  <p>Thank you in advance.</p>
  
  <p><strong>CODE</strong></p>
  
  <pre><code>Private Sub maybe()
  
      Dim sht As Worksheet: Set sht = Worksheets("Sheet3")
      Dim wk_cnt As Double: wk_cnt = sht.Range("A1", sht.Range("A1").End(xlDown)).Rows.Count
      Dim bld_cnt As Double: bld_cnt = sht.Range("C2", sht.Range("C2").End(xlDown)).Rows.Count
      Dim cnt As Double
      Dim yrs_cnt As Double
          If sht.Range("D3").Value = "" Then
              yrs_cnt = 1
          Else:
              yrs_cnt = sht.Range("D2", sht.Range("D2").End(xlDown)).Rows.Count
          End If
      Dim yrsArray As Range
          If sht.Range("D3").Value = "" Then
              Set yrsArray = sht.Range("D2")
          Else:
              Set yrsArray = sht.Range("D2", sht.Range("D2").End(xlDown))
          End If
      Dim vCnts As Variant
  
      ReDim vCnts(1 To 12, 1 To yr_cnt)
          vCnts(1, 1) = "Irving Building"
          vCnts(2, 1) = "Memorial Building"
          vCnts(3, 1) = "West Tower"
          vCnts(4, 1) = "Witting Surgical Center"
          vCnts(5, 1) = "Madison Irving Surgery Center"
          vCnts(6, 1) = "Marley Education Center"
          vCnts(7, 1) = "410 South Crouse"
          vCnts(8, 1) = "Physicians Office Building"
          vCnts(9, 1) = "Crouse Business Center"
          vCnts(10, 1) = "Commonwealth Place"
          vCnts(11, 1) = "Crouse Garage"
          vCnts(12, 1) = "CNY Medical Center"
  
      For x = 1 To yrs_cnt
          cnt = 0
          For y = 2 To wk_cnt
              If Year(sht.Cells(y, 1).Value) = sht.Cells(1, x + 5).Value Then
                  cnt = cnt + sht.Cells(y, 2).Value
                  sht.Cells(14, x + 5) = cnt
              End If
          Next y
      Next x
  
  End Sub
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>With Column C</p>
  
  <p><a href="https://i.stack.imgur.com/SrL20.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SrL20.png" alt="With Long Column"></a></p>
  
  <p>With only Columns A &amp; B</p>
  
  <p><a href="https://i.stack.imgur.com/34CkT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/34CkT.png" alt="enter image description here"></a></p>
  
  <p>I need the numbers to match the second image, but when I include all three columns it looks like the first image after I group it by years year.  How can I fix that?</p>