title: Excel VBA If Then Loop conditions
body: <p>I've been struggling with this for a few days.  Any help would greatly be appreciated!</p>
  
  <p>It's difficult to explain, so I'll do my best.</p>
  
  <p>What I'm trying to do is count the number of results each query has and then categorize them based on that result count.</p>
  
  <p>For example if Query_A has 1 exact result and then Query_Z has 1 exact result then that would be a total of 2 queries that have 1 result.</p>
  
  <p>I'm currently trying to use Loop with if then statements, but I'm at a loss.</p>
  
  <p>Here is some example data and the output I was hoping for: <a href="http://www.seoknow.us/Query_Example_Data_and_Results.xlsx" rel="nofollow">Query_Example_Data_and_Results.xlsx</a> - This is not my real spreadsheet as it is thousands of rows of data and a very large file size.</p>
  
  <p>The code below does pull the query count (removing the query dupes), but does not give the query result count..  I would have provide my code attempts, but I know I'm not even close...  So I have removed my failed attempts hoping I'm being clear enough to get steered in the right direction.</p>
  
  <pre><code>Sub Query_Count()
  
  G_40 = 0
  
  Query = ""
  
  Application.StatusBar = " ~~ ~~ QUERY COUNT ~~ RUNNING ~~ ~~ " &amp; x
  
  x = 2
  
  Do Until Sheets(1).Cells(x, 1) = ""
  
      If Sheets(1).Cells(x, 9) = "Yes" Then
      If Query &lt;&gt; Sheets(1).Cells(x, 1) Then
          G_40 = G_40 + 1
      End If
      End If
      Query = Sheets(1).Cells(x, 1)
  
  x = x + 1
  
  Loop
  
  Application.StatusBar = "DONE RUNNING QUERY COUNT OF " &amp; x &amp; " ROWS!"
  
  G = 40
  Sheets(3).Cells(G, 7) = G_40 'query_count:
  
  End Sub
  </code></pre>
  
  <p>Thank you in advance!</p>