title: Simple Do Until Loop in VBA
body: <p>I am new to Excel VBA and have a simple question. Once I understand how to to this loop, I can build on it.</p>
  
  <p>I would like to automate a classification. The data repeats itself in a single column i.e sampleA, sampleA, sampleA, sampleB, sampleB, sampleC, sampleC, sampleC, etc. I would like my macro to identify when the sample name changes between the sample names. So, for example, when the following cell after sampleA turns into sampleB, I would like the macro to understand that there is a change and write a phrase next to this (this will next turn into an equation with the data in the sample's respective rows but baby steps :)  ).</p>
  
  <p>Overall, the macro needs to sense the changes between a column of identical sample names until a new name is reached. </p>
  
  <p>I have been researching solutions and the "do until" loop seems to be the closest solution to what I need. Also, to show that sampleA is not the same as sampleB I used &lt;>.</p>
  
  <pre><code>Sub DoUntilStringMacro()
  
  Dim sampleA As String
  
  Dim sampleB As String
  
  Dim sampleC As String
  
  Dim classification As String
  
      Do Until ActiveCell.Value = ""
  
          If sampleA &lt;&gt; sampleB Then
              classification = "hello"
          ElseIf sampleB &lt;&gt; sampleC Then
              classification = "goodbye"
          ElseIf sampleC &lt;&gt; sampleA Then
              classification = "see you soon"
          End If
  
          answer = classification
          Cells(classification, "B").Value = answer
  
      Loop
  
  End Sub
  </code></pre>
  
  <p><strong>Actual results:</strong> error at   Cells(classification, "B").Value = answer
  Something is wrong here. I am trying to display results in column "B".</p>
  
  <p><strong>Expected results on Excel Worksheet in columns:</strong></p>
  
  <pre><code>Sample:  Classification
  sampleA  --
  sampleA  --
  sampleA  hello
  sampleB  --
  sampleB  goodbye
  sampleC  --
  sampleC  --
  sampleC  see you soon
  </code></pre>