title: Excel macro scan a cell for multiple values. and loop
body: <p>Below I have a program that will go to a sheet (Inventory), look at the employee name, column A, if its the same as above (Last time)</p>
  
  <p><code>If Cells(i &amp; ",1").Value = Cells(i - 1 &amp; ",1").Value Then</code> </p>
  
  <p>then look at a description in column B and if it isn't on the ones that I need, go to the next line and repeat. If it is what I need then copy the row back to sheet J and copy onto there. Rinse Lather Repeat.  However at the moment all it is doing is adding another value to i and moving on, meaning that it is just skipping every second line. What loop do I need to add to make it recheck the next line, ie i=3 for the same thing and possibly discard that as well?</p>
  
  <p>For bonus points, the column A scan is not working. Help on that would be great.      </p>
  
  <pre><code>Dim i As Integer
  Dim j As Integer
  Dim k As Integer
  
  i = 2
  j = 73
  k = 3
  
  ActiveCell.FormulaR1C1 = "Inventory"
  Sheets("Inventory").Select
  Do Until i = 4495
     If Cells(i &amp; ",1").Value = Cells(i - 1 &amp; ",1").Value Then
         Sheets("Inventory").Select
         Application.ScreenUpdating = False
         If Cells(i &amp; ",2").Text &lt;&gt; "CONSUMABLES" _
             Or Cells(i &amp; ",2").Text &lt;&gt; "FILTERS - BILLI TRIO" _
             Or Cells(i &amp; ",2").Text &lt;&gt; "FILTERS - ZIP GENERIC" _
             Or Cells(i &amp; ",2").Text &lt;&gt; "GOODS" _
             Or Cells(i &amp; ",2").Text &lt;&gt; "HARDWARE FIXINGS" _
             Or Cells(i &amp; ",2").Text &lt;&gt; "LIGHTING - 50W DICHROIC" _
             Or Cells(i &amp; ",2").Text &lt;&gt; "LIGHTING - COMPACT BC/ES" _
             Or Cells(i &amp; ",2").Text &lt;&gt; "LIGHTING - DICHROIC LAMP" _
             Or Cells(i &amp; ",2").Text &lt;&gt; "LIGHTING - FLURO" _
             Or Cells(i &amp; ",2").Text &lt;&gt; "LIGHTING - PLC LAMP 840/830" _
             Or Cells(i &amp; ",2").Text &lt;&gt; "LIGHTING - PL-L" _
             Or Cells(i &amp; ",2").Text &lt;&gt; "LIGHTING - PULSE STARTER" _
             Or Cells(i &amp; ",2").Text &lt;&gt; "LIGHTING - STANDARD STARTER" _
             Or Cells(i &amp; ",2").Text &lt;&gt; "LIGHTING - T5 FLURO" _
             Or Cells(i &amp; ",2").Text &lt;&gt; "NITROGEN CHARGE" _
             Or Cells(i &amp; ",2").Text &lt;&gt; "OXYGEN / ACETYLENE WELDING" _
             Or Cells(i &amp; ",2").Text &lt;&gt; "R-134A" _
             Or Cells(i &amp; ",2").Text &lt;&gt; "R-22" _
             Or Cells(i &amp; ",2").Text &lt;&gt; "R-407C" _
             Or Cells(i &amp; ",2").Text &lt;&gt; "R-410A" = 0 Then   
                 i = i + 1
         Exit If
     Rows(i).Select
     Selection.Copy
     Sheets("Sheet" &amp; j).Select
     Rows(k).Select
     ActiveSheet.Paste
     i = i + 1
     k = k + 1
  Else
  </code></pre>