title: VBA Countif two sets of criteria match
body: <p>I am trying to count each "Three" if and only if it follows "Two". I have a list of data in one column (G1:G100) that alternates between "One, Two and Three" and I am just looking for the count of how many times three follows two.</p>
  
  <p>The code I was using searches for each instance and adds the but as I explained I want it to count only each instance if the condition is met.</p>
  
  <pre><code>Sub sample()
  Dim wsMain As Worksheet: Set wsMain = ThisWorkbook.Sheets("sheet1")
  Dim k As Long
  
  'get count of cells that start with ring
  k = Application.WorksheetFunction.CountIf(Columns(7), "Two") + Application.WorksheetFunction.Countif(Columns(7)
  
  If k &gt; 0 Then
      Range("C2").Value = k
      End If
  
  
  End Sub
  </code></pre>