• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 468
  • Last Modified:

how to create a dynamic print area

hi Folks
How can I create a print area in Excel 2010 to be dynamic so that when new data is added, the print area expands automatically? Thank you
0
agwalsh
Asked:
agwalsh
5 Solutions
 
Rgonzo1971Commented:
0
 
SreeramCommented:
HI

Using Macro also can be done

sample code:

Sub Macro1()

    With ActiveSheet.PageSetup
        .PrintArea = "$A$1:$D$" & lastinsertedrow
    End With
   
End Sub

Note:

lastinsertedrow - insert the last used row number


this code will set the print area to the range A1 to Dlastinsertedrow
0
 
Rgonzo1971Commented:
HI,

With a macro, I would rather do it like this so you have it all automatic

Sub Macro1()
    With ActiveSheet
        .PageSetup.PrintArea = .UsedRange.Address
    End With
End Sub

Open in new window

Regards
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
yuppyduCommented:
Why don't you simply create a variable range name and point to it?

If what you need to print is in range A1 to C40 on Sheet1 and you add items either vertically or horizontally you can name the range as PrintRange and input the following string in the Refers to:
=OFFSET(Sheet1!$A$1;0;0;COUNT(Sheet1!A:A);COUNT(Sheet1!1:1))

Then you print PrintRange
0
 
Rob HensonIT & Database AssistantCommented:
Do you want the Print Area to be all rows and all columns of the Active Sheet.

If so, just delete the Print Area settings altogether and let the Automatic Print Range to kick in.

Thanks
Rob H
0
 
agwalshAuthor Commented:
What I did in the end was a version of what was here. I set up a dummy print area and then amended the Print Range range name to read ='Name of Sheet'!$A:$A,'Name of Sheet'!$1:$2
And that actually worked well. Checked it with adding and deleting rows and it worked fine. But thank you all :-)
0
 
agwalshAuthor Commented:
I've given you all equal marks to say thank you...but I've marked RobHenson's one as best because it was the closest to what worked for me. But THANK YOU to all of you :-)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now