title: Deleting or keeping multiple rows by a specific word content
body: <p>I'm trying to write a code that either deletes or keeps rows by a specific word input by the end-user. </p>
  
  <p>I've created two button actions:</p>
  
  <pre><code>Sub Button1_Click()
  Dim cell As Range
  word1 = InputBox("Enter a word by which you want to keep rows", "Enter")
  For Each cell In Selection
      cell.EntireRow.Hidden = (InStr(1, cell, word1, 1) = 0) 'keep by a word input by the user
  Next
  End Sub
  
  Sub Button2_Click()
  Dim cell As Range
  word2 = InputBox("Enter a word by which you want to delete rows", "Enter")
  For Each cell In Selection
      cell.EntireRow.Hidden = (InStr(1, cell, word2, 1) = 1) 'delete by a word input by the user
  Next
  End Sub
  </code></pre>
  
  <p>However, these buttons don't work quite the way I would like them to do.</p>
  
  <p>Problems:</p>
  
  <p>1) I have to specifically select the cells in the column of the text to be searched; if I select the whole block of data,everything will be deleted.</p>
  
  <p>2) Actually, the program would be handier, if it did its magic from the cell J22 onwards (to the right and downwards) until the end of the data is reached, without the need to select anything. What is the best way to do this?</p>
  
  <p>3) If I use these buttons several times sequentially, the rows that I've already deleted keep popping up again. How to make the delete "permanent" each time I use one of these buttons? By changing Hidden to Delete I start to get run-time errors.</p>