Solved

how to create a dynamic print area

Posted on 2014-01-10
7
438 Views
Last Modified: 2014-01-14
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
Comment
Question by:agwalsh
7 Comments
 
LVL 49

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 200 total points
ID: 39770693
0
 
LVL 3

Assisted Solution

by:Sreeram
Sreeram earned 100 total points
ID: 39770712
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
 
LVL 49

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 200 total points
ID: 39770816
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
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 
LVL 4

Assisted Solution

by:yuppydu
yuppydu earned 100 total points
ID: 39775892
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
 
LVL 32

Accepted Solution

by:
Rob Henson earned 100 total points
ID: 39776318
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
 

Author Comment

by:agwalsh
ID: 39778681
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
 

Author Closing Comment

by:agwalsh
ID: 39778685
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will show you how to use shortcut menus in the Access run-time environment.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question