Atomix
Atomix

Reputation: 125

Macro for setting print area not working

I would like to create a simple macro which will set a print area from selected area but i still get an error "Subscript out of range"

Here's the code

Worksheets("Zeszyt11").Activate ActiveSheet("Arkusz1").PageSetup.PrintArea = _ActiveCell.CurrentRegion.Address

EDIT

Ok,i've got one more question: I would like to make a print area only out of cells i've selected,now it takes every with any text..How to fix it ?

Upvotes: 0

Views: 472

Answers (1)

QHarr
QHarr

Reputation: 84465

You can't say ActiveSheet("SheetName") try

Worksheets("Arkusz1").PageSetup.PrintArea = ActiveCell.CurrentRegion.Address

Upvotes: 1

Related Questions