LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Macro - Set Print Area for Changing Data Area

Excellent post, I used this to solve a problem I was having and wanted to
share a variation.

I have a similar situation except I copy many different bunches of data to
many different worksheets. The following function will leave the existing
print settings the same (assuming you set them up once), but changes the end
row of the print range to fit the current data set.

Sub UpdatePrintAreas()
'example function call, I use range names because the worksheet
names/positions change

AutoSetPrintArea Range("CopyFunctionData")
AutoSetPrintArea Range("CopyProcessData")
AutoSetPrintArea Range("CopyFinancialData")
End Sub


Function AutoSetPrintArea(MyRange As Range)

Dim LastRow As Long

With MyRange.Worksheet
LastRow = .Cells(.Rows.Count, "D").End(xlUp).Row
.PageSetup.PrintArea = Left(.PageSetup.PrintArea,
Len(.PageSetup.PrintArea) - 2) & LastRow
End With

End Function



"Leith Ross" wrote:


Hello Karen,

Sorry about that. I made a typo. I'll correct the post also.

Change that line to...
LastRow = .Cells(.Rows.Count, "D").End(xlUp).Row

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=487498


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
set area in excel not giving me option to set print area? J Littlebear Excel Discussion (Misc queries) 4 April 23rd 23 09:04 PM
File, print area, clear area, is not working cblind New Users to Excel 2 September 12th 07 04:51 PM
Pivot Table macro to set print area and print details of drill down data Steve Haskins Excel Discussion (Misc queries) 2 December 28th 05 04:59 PM
Changing print area Aaron Excel Discussion (Misc queries) 2 January 9th 05 05:58 PM
Changing Print area JT[_2_] Excel Programming 2 May 9th 04 04:06 AM


All times are GMT +1. The time now is 07:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"