Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Adding new rows to spreadsheet

Here's a scenario:

I have a macro that prints the range a1:c52. I then add
a few rows within this range. How do I get the macro to
adjust the print range to include the new range?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Adding new rows to spreadsheet

Range("A1").CurrentRegion.Printout

--
Regards,
Tom Ogilvy

"Roy" wrote in message
...
Here's a scenario:

I have a macro that prints the range a1:c52. I then add
a few rows within this range. How do I get the macro to
adjust the print range to include the new range?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default Adding new rows to spreadsheet

Roy

Making an assumption that the column will only extend to C the code below
finds the last row with data. Goes to row 65536 and looks up in columnA and
uses this to set the print area to that address.

You can use the relevant parts in your code

Sub setprintrange()
Dim lLastRow As Long
lLastRow = Range("A65536").End(xlUp).Row
Worksheets("Sheet1").PageSetup.PrintArea = Range("A1:C" & lLastRow).Address
End Sub

If the column differs you could use other methods in place of this. This
example from help
This example sets the print area to the current region on Sheet1. Note

that you use the Address property to return an A1-style address.

Worksheets("Sheet1").Activate
ActiveSheet.PageSetup.PrintArea = _
ActiveCell.CurrentRegion.Address


--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS



Roy wrote:
Here's a scenario:

I have a macro that prints the range a1:c52. I then add
a few rows within this range. How do I get the macro to
adjust the print range to include the new range?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Adding new rows to spreadsheet

Thanks for your help.
-----Original Message-----
Roy

Making an assumption that the column will only extend to

C the code below
finds the last row with data. Goes to row 65536 and

looks up in columnA and
uses this to set the print area to that address.

You can use the relevant parts in your code

Sub setprintrange()
Dim lLastRow As Long
lLastRow = Range("A65536").End(xlUp).Row
Worksheets("Sheet1").PageSetup.PrintArea = Range("A1:C"

& lLastRow).Address
End Sub

If the column differs you could use other methods in

place of this. This
example from help
This example sets the print area to the current

region on Sheet1. Note
that you use the Address property to return an A1-style

address.

Worksheets("Sheet1").Activate
ActiveSheet.PageSetup.PrintArea = _
ActiveCell.CurrentRegion.Address


--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England




Roy wrote:
Here's a scenario:

I have a macro that prints the range a1:c52. I then

add
a few rows within this range. How do I get the macro

to
adjust the print range to include the new range?



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Adding new rows to spreadsheet

Thanks for your help.
-----Original Message-----
Range("A1").CurrentRegion.Printout

--
Regards,
Tom Ogilvy

"Roy" wrote in

message
...
Here's a scenario:

I have a macro that prints the range a1:c52. I then

add
a few rows within this range. How do I get the macro

to
adjust the print range to include the new range?



.

Reply
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
Adding rows based on no of rows specified from a given position nanette Excel Worksheet Functions 1 July 9th 08 02:29 PM
Adding new rows to an Excel spreadsheet niletrader Charts and Charting in Excel 0 October 21st 07 10:51 PM
Adding five new rows every 40 rows in a spreadsheet? Olzki Excel Discussion (Misc queries) 8 May 18th 07 02:14 AM
Adding Rows offsets to working rows across two worksheets tom Setting up and Configuration of Excel 3 July 30th 06 07:54 PM
Sum only adding rows on page instead of entire spreadsheet - help Sarah Excel Discussion (Misc queries) 1 February 15th 06 11:46 PM


All times are GMT +1. The time now is 10:31 AM.

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"