macro that prints visible area after filter in excel

后端 未结 2 1549
没有蜡笔的小新
没有蜡笔的小新 2021-01-27 06:20

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

2条回答
  •  北荒
    北荒 (楼主)
    2021-01-27 07:09

    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

提交回复
热议问题