Looping Through All Cells in a Column and checking if each cell contains a string within string
<p>I run an excel report weekly and need to replace all of the values in a certain column depending on which strings are existent within the different values. </p>

<p>I have already learned a lot about how to loop through the column from stack overflow , as well as about the instr function but my macro still is not working. Also, many of the solutions that I have found require a actual string to search, but since this changes every time, I need to search through a range. Hoping that someone can help me figure out why...thank you in advance!</p>

<pre><code>Sub FlagReplace()
Dim flagcell As String

rowcount = WorksheetFunction.Count(Range("H:H"))
For i = 2 To rowcount
flagcell = Cells(i, 8).Value

   If InStrB(1, flagcell, "flag_green", vbBinaryCompare) &lt;&gt; 0 Then
       Cells(i, 8).Value = "last month"
   ElseIf InStrB(1, flagcell, "red", vbBinaryCompare) &lt;&gt; 0 Then
       Cells(i, 8).Value = "not last month"
   End If
Next

End Sub
</code></pre>