title: VBA Excel Unfiltering but not unhiding rows
body: <p>I am writing a code to filter certain data and copy it. After which, I want to unfilter it to its original state. I am using the ActiveSheet.ShowAllData statement but that unhides all the hidden rows as well. Is there a set of code that allows me to unfilter my filtered data but not unhide any rows that were previously hidden?</p>
  
  <p>Thanks for answering</p>
  
  <p>EDIT: This is the code if it helps.</p>
  
  <p>Sub CopyToAmortizing()</p>
  
  <pre><code>Dim tbl As Range
  Dim VisibleCells As Integer
  Dim lr As Long
  
  Sheets("Template").Select
  Columns("A:AZ").EntireColumn.Hidden = False
  If Not ActiveSheet.AutoFilter Is Nothing Then Cells.AutoFilter
  Range("A5:AB5").Select
  Range(Selection, Selection.End(xlDown)).Select
  Set tbl = Selection
  
  ActiveSheet.Range("$A$3:$N$9999").AutoFilter Field:=1, Criteria1:= _
      "Amortizing Item"
  </code></pre>
  
  <p>On Error GoTo Point2</p>
  
  <pre><code>VisibleCells = tbl.SpecialCells(xlCellTypeVisible).Rows.Count
  If VisibleCells &gt;= 1 Then
  
  Range("A3").Select
  Selection.End(xlDown).Activate
  lr = ActiveCell.Row
  
  Range("B3", Cells(lr, 12)).Select
  Selection.Copy
  Sheets("AmortizingItems").Select
  Range("A2").Select
  Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
      xlNone, SkipBlanks:=False, Transpose:=False
  Application.CutCopyMode = False
  Rows(2).EntireRow.Delete
  Range("A2").Select
  Sheets("Template").Select
  End If
  </code></pre>
  
  <p>Point2:</p>
  
  <pre><code>ActiveSheet.ShowAllData
  Columns("A:AZ").EntireColumn.Hidden = False
  ActiveSheet.Outline.ShowLevels RowLevels:=0, ColumnLevels:=1
  Range("A5").Select
  </code></pre>
  
  <p>End Sub</p>
  
  <p>I use filter: 
  ActiveSheet.Range("$A$3:$N$9999").AutoFilter Field:=1, Criteria1:= _
          "Amortizing Item"
  And then: ActiveSheet.ShowAllData</p>