title: How do I perform a function in sequential dynamic ranges?
body: <p>VBA newbie here.  I did find some information out there about coding these loops but I'm having a very hard time figuring out if and/or how it applies to my specific needs, so thank you in advance for any help you can give.</p>
  
  <p>In order to QA information before it's formatted and uploaded, I want to cycle through multiple groups of dynamic ranges and check the information against another column within that range.  Each range is grouped by an email address in column D, and I need to make sure that the same email is also listed in column G (I am going to delete columns B-D before upload).  Since each grouping could be anywhere from 1 to 100 rows, I have coded how to define the ranges (below), but how can I add a loop to perform the check in each group individually?</p>
  
  <p>The output for all of this should be a message box that either says, "All clear!" if the code finds no errors, or "[Name] isn't listed.  Please add their information before continuing." if they aren't listed.</p>
  
  <p>I'm assuming I should do some sort of Do While or Do Until or For loop for this, but then I get confused conceptually on whether to declare my variables in or outside of the loops and then how to concatenate possibly multiple unlisted names into the same message box at the end.</p>
  
  <p>Here's what I have so far:</p>
  
  <pre><code>Sub QANameIsListed()
  'Declare the variables.
  Dim nRow As Long
  Dim nStart As Long, nEnd As Long
  Dim sEmail As String
  Dim sName As String
  
  'Figure out what first email address is.
  sEmail = Range("D2").Text
  
  'Figure out where first group data starts.
  For nRow = 1 To 65536
      If Range("D" &amp; nRow).Value = sEmail Then
          nStart = nRow
      End If
  Exit For
  Next nRow
  
  'Figure out where first group data ends.
  For nRow = nStart To 65536
      If Range("D" &amp; nRow).Value &lt;&gt; sEmail Then
          nEnd = nRow
      End If
  Exit For
  Next nRow
  nEnd = nEnd - 1
  
  'Check whether the name is listed in the second column.
  With Range("G" &amp; nStart &amp; ":G" &amp; nEnd)
  sName = Range("B" &amp; nStart).Text &amp; " " &amp; Range("C" &amp; nStart).Text
      Set c = .Find(sEmail)
      If c Is Nothing Then
          MsgBox (sName &amp; " " &amp; "isn't listed." _
          &amp; "  " &amp; "Please add their information before continuing.")
      Else
          MsgBox ("All clear!")
      End If
  End With
  End Sub
  </code></pre>