简体   繁体   中英

Excel VBA choose cells to print - Set Print Area

I want to choose the print area using VBA and print them out.

I have tried this method, but it gives me an error

This formula is missing a range reference or a defined name

Worksheets("Printable Version").Activate
With Sheets("Printable Version")
    ActiveSheet.PageSetup.PrintArea = .Range("A1").Value & ":" & .Range("G55").Value
End With
With Sheets("Printable Version")
    .PageSetup.PrintArea = .Range("A1:G55").Address
    '''Or
    .PageSetup.PrintArea = "A1:G55"
    .PrintOut
End With

我用这段代码弄清楚了:

WorkSheet("sheetname").range("A1:G55").printout

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM