title: Keep rows with specific text and delete all the rest of rows in all worksheets
body: <p>I'm trying to keep rows with specific words and delete the rest but I have two problems. I'm not an expert in Excel VBA so I need your help.</p>
  
  <ol>
  <li><p>I'm trying to keep rows that contain more than one text.(How to add text 1, text 2, Text 3). In the code below it's only one word(Text).</p></li>
  <li><p>There are 27 sheets and some sheets are hidden and all data in each sheet is in table format. The code below for some reason gives error when I'm trying with table format. It works when it's applied to non-table format though.</p></li>
  </ol>
  
  <p>How can I fix these two issues in this code?</p>
  
  <pre><code>Sub WorksheetLoop()
  
   Dim c As Integer
   Dim n As Integer
   c = ActiveWorkbook.Worksheets.Count
   For n = 1 To c Step 1
      Last = Worksheets(n).Cells(Rows.Count, "A").End(xlUp).Row
      For i = Last To 1 Step -1
          If (Worksheets(n).Cells(i, "A").Value) &lt;&gt; "Text" Then
              Worksheets(n).Cells(i, "A").EntireRow.Delete
          End If
      Next i
   Next n
   End Sub
  </code></pre>
  
  <p>Thanks in advance for your help</p>