Home » excel » excel – Set range variable = printarea

excel – Set range variable = printarea

Posted by: admin April 23, 2020 Leave a comment


Trying to set a range variable = to current print area.

dim rng as range
Set rng = ActiveSheet.PageSetup.PrintArea

There is more to it than this, but this is where I am getting stuck, Getting a
Run-time error ‘424’:
Object required

I am assuming this is because the printarea is text and the variable I am using is set as a range. How do I get my rng variable set to printarea range?

How to&Answers:

As long as the PrintArea is already assigned a value you can turn it into a range object like this:

Dim rng As Range

'This has to be set or print area returns a blank string
'which will cause the set statement below to throw an error
ActiveSheet.PageSetup.PrintArea = "A1:B1"

Set rng = Range(ActiveSheet.PageSetup.PrintArea)