I would like to filter my table, then use a macro to go over every ID that is still visible, past this on the form of the next sheet and print that sheet. I made the following piece of code and it works as I want it too. I opened the file to day and tried to save it but I couldn't save it. So, I copied everything to a new workbook including my VBA and the same thing happened. After I closed it and opened it again, I got an error. So my question is, is there something wrong with my code?
VBA Code:
Sub Print_Form_Visible_Ids()
Dim tbl As ListObject
Dim rngTable As Range
Dim rngArea As Range
Dim rngRow As Range
Set tbl = ActiveSheet.ListObjects(1)
Set rngTable = tbl.DataBodyRange.Columns(1).SpecialCells(xlCellTypeVisible)
Debug.Print "Filtered table: " & rngTable.Address
For Each rngArea In rngTable.Areas
Debug.Print " Area: " & rngArea.Address
For Each rngRow In rngArea.Rows
Debug.Print " Row: " & rngRow.Address
'# Here
Range(rngRow.Address).Select
Selection.Copy
Sheets("Sheet2").Select
Range("B2").Select
ActiveSheet.Paste
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Sheets("Sheet1").Select
Next
Next
End Sub