I have a macro that filters the table based on column A
values. Now I want to print only the visible rows after the filter, but sadly it prints all of the rows including the top and bottom rows that were hidden during the filter.
In my sheet, there are data from Column A:I
, but the print area should only be Columns C:I
- visible rows after filter.
Here are the codes that I've tried so far that didn't work:
Code 1:
ActiveSheet.PageSetup.printarea = Range("C3:I81000").Rows.SpecialCells(xlCellTypeVisible)
Code 2:
Dim lastrow As Long
lastrow = ActiveSheet.UsedRange.Rows.Count
Range(Cells(3, 3), Cells(lastrow, 9)).Select
ActiveSheet.PageSetup.printarea = Selection.Address
Any other suggestions?
Finally, this code worked! :) Thanks to all!
Depending on what you need the code for, I just confirmed that the following snippet works:
Please activate the "PrintOut" row only if you want the command to be send to the printer.
For some reason. the "Selection" for rows works better for hidden/filtered cells, than other options of selection rows.
Hope that helps Best seulberg1