title: Counting Rows in column of a cell
body: <p>I am trying to loop over each staff members roster and automate slotting them into a free session. Part of this is counting rows in column of current cell (Session)</p>
  
  <p>The <strong>Roster</strong> data looks like
  <a href="https://i.stack.imgur.com/2scoJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2scoJ.jpg" alt="enter image description here"></a></p>
  
  <p>The <strong>sessions</strong> data looks like</p>
  
  <p><a href="https://i.stack.imgur.com/US4Cu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/US4Cu.jpg" alt="enter image description here"></a></p>
  
  <p>The code so far is :</p>
  
  <pre><code>Sub ScheduleSession()
  Dim Roster As Worksheet
  Dim Sessions As Worksheet
  Dim LastRow As Long
  Dim x As Long
  Dim row As Range
  Dim Session As Range
  
  With ActiveWorkbook.Worksheets("Roster")
  LastRow = .Cells(.Rows.Count, "A").End(xlUp).row
  For x = LastRow To 8 Step -1
  
      If IsEmpty((.Range("B" &amp; x))) Then
          ' Look for a session
          Debug.Print ("Looking For a Session for " &amp; (.Range("A" &amp; x)))
                  For Each Session In ActiveWorkbook.Worksheets("Sessions").Range("A1:E1").Cells
                      Debug.Print (Session)
                      ' Check session is not full (3 per session) else next session
                      SessionCount = Cells(Rows.Count, Session.Columns.Count).End(xlUp).row
                      If (SessionCount &gt; 4) Then
                          Exit For
                      Else
                          ' Loop over cells in employee roster to see if they are working on given day and time.
                          ' If so roster them by recording session against employee (on ROSTER col B) and employee against session in appropriate col on SESSIONS
                      End If
                  Next
  
      Else
          ' Employee already scheduled
          Debug.Print ("This employee " &amp; (.Range("A" &amp; x)) &amp; " already has a session")
      End If
  
  Next x
  End With
  </code></pre>
  
  <p>Can I please get help with counting the rows in the For Each Session loop line which current is a Run-time Error 91 - Object Variable with Block Variable Not Set. </p>
  
  <p>This question has been answered many times, but the other answers I see don't show how to apply it to a range like Session.</p>
  
  <p>If anyone is feeling generous some guidance on going to the employee roster from each session to check if they are working and available to be scheduled would be great.</p>
  
  <p><strong>UPDATE</strong> Sorry Sessions is Session</p>
  
  <pre><code>SessionCount = Cells(Rows.Count, Session.Columns.Count).End(xlUp).row
  </code></pre>
  
  <p>Since I need the number of rows in the current session in the For Each Session loop.</p>