Set range variable = printarea

Attempting to set range variable = current print area. In the meantime, there is no need to know about it. ”

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

      

It's more than that, but this is where I get stuck. Run-time error "424": Required object

I assume this is because printarea is text and the variable I am using is set as a range. How do I get the value of the rng variable for the printarea range?

+3


source to share


1 answer


As long as the PrintArea is already assigned a value, you can turn it into a range object, for example:



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)

      

+3


source







All Articles