title: excel vba count number of blank cells below each non empty cells
body: <p>I am quite new with Excel VBA. What I want to do is create a VBA loop that will count the number of cells below each non empty cells.</p>
  
  <pre><code>col c   col d
  abc     1
          2
          3
          4
  abc     5
          6
          7
          8
          9
          10
  </code></pre>
  
  <p>Here's what I've tried so far:</p>
  
  <pre><code>Sub test()
  
  Dim a, b, c, d, i, k As Integer
  Dim y As Range
  
  k = Worksheets("Sheet2").Range("d" &amp; Rows.Count).End(xlUp).Row '13
  a = 3
  b = 3
  
  For i = 4 To k                        
      If IsEmpty(Cells(i, 3)) = True Then        
          c = c + 1                    
      Else        
          d = d + 1            
      End If    
  Next
  
  MsgBox c
  MsgBox d
  
  End Sub
  </code></pre>