title: VBA what is more optimal: filtering hidden rows
body: <p>I need to filter a excel sheet with more than 50000 rows 512 times. I am currently using the following code.</p>
  
  <pre><code>Do While Not IsEmpty(ActiveCell.value)
  
          Worksheets("Sheet1").Activate
          filtro = ActiveCell.value
  
          Sheets("Sheet2").Select
          Range("D1").Select
          Selection.AutoFilter
          ActiveSheet.Range("$A$1:$I$" &amp; lastRow("D")).AutoFilter Field:=4, Criteria1:=filtro
  
          Range("A1").Select
  
          Do While Not IsEmpty(ActiveCell.value)
  
              Do
  
                  ActiveCell.offset(1, 0).Select
                  oProgress.Increase 1
  
              Loop While ActiveCell.EntireRow.Hidden = True
  
                  Call functio ' this function do something with the actual row
  
          Loop
  
      Loop
  </code></pre>
  
  <p>The problem is it's taking so much time to analyse 50000 rows X 512 times!, I was thinking maybe it is better to filter and then copy the rows into a temporary sheet, and check the values there?.</p>
  
  <p>The line Active is processed by the function readValues</p>