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
Depending on what you need the code for, I just confirmed that the following snippet works:
Public Sub Test()
Range("C3").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.PageSetup.PrintArea = Selection.Address
'ActiveSheet.PrintOut
Range("C3").Select
End Sub
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
Finally, this code worked! :) Thanks to all!
ActiveSheet.PageSetup.PrintArea = Range("C3:I" & lastrow).Rows.SpecialCells(xlCellTypeVisible).Address