Barry Wang
Barry Wang

Reputation: 101

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

Upvotes: 1

Views: 8053

Answers (2)

Barry Wang
Barry Wang

Reputation: 101

I figured it out bu using this piece of code:

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

Upvotes: 1

R3uK
R3uK

Reputation: 14547

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

Upvotes: 1

Related Questions