Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Creating print areas automatically using VBA

I have an Excel file in which a worksheet contains 365 identical tables
except for the date.

I wish to make all these tables individual print areas i.e end up with 365
print areas.

I wish to do this automatically using VBA code.

My only attempt to was use the following code on each table using a loop.

Sub PrintArea()

Application.ScreenUpdating = False

Worksheets("Sheet1").Activate

For t = 1 To 13141 Step 36

Range("A1")(t).Activate

ActiveSheet.PageSetup.PrintArea = ActiveCell.CurrentRegion.Address

Next t

Application.ScreenUpdating = True

End Sub

I used Step Into to view the operation of the code one line at a time.

Unfortunately as soon as the second table became a print area the first
table print area was deselected
As soon as the third table became a print area the second table print area
was deselected and so on.

The result of running the code was simply to make the last table a print
area.

Any suggestions please ?

I am quite willing to upload a copy of the file if this is at all possible.

--
FLYNNE
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Creating print areas automatically using VBA

There is only one print area per sheet. The behavior you describe is exactly
what I would expect.

The question is, what are you trying to accomplish with this?

Are you trying to do a print and have each table print out on a separate
sheet?

Perhaps a clearer explanation of what you hope to achieve will result in a
suggestion on how to approach the problem.

I wish to make all these tables individual print areas i.e end up with 365
print areas.


so you see that is not possible - but what funtionality are you trying to
achieve?



--
Regards,
Tom Ogilvy


"FLYNNE" wrote:

I have an Excel file in which a worksheet contains 365 identical tables
except for the date.

I wish to make all these tables individual print areas i.e end up with 365
print areas.

I wish to do this automatically using VBA code.

My only attempt to was use the following code on each table using a loop.

Sub PrintArea()

Application.ScreenUpdating = False

Worksheets("Sheet1").Activate

For t = 1 To 13141 Step 36

Range("A1")(t).Activate

ActiveSheet.PageSetup.PrintArea = ActiveCell.CurrentRegion.Address

Next t

Application.ScreenUpdating = True

End Sub

I used Step Into to view the operation of the code one line at a time.

Unfortunately as soon as the second table became a print area the first
table print area was deselected
As soon as the third table became a print area the second table print area
was deselected and so on.

The result of running the code was simply to make the last table a print
area.

Any suggestions please ?

I am quite willing to upload a copy of the file if this is at all possible.

--
FLYNNE

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Creating print areas automatically using VBA

Thanks Tom for your rapid reply and the info given. I shall try this out
shortly.
However you say you can only have one print area per worksheet.

I have created a file with a worksheet having 8 print areas.

These are created by selecting the 1st area , then while holding down Ctrl
selecting all the remaining areas.

I convert all of these to print areas by clicking on File ----- Print Area
------ Set Print area .

The purpose of these multi print areas is to print out some or all of these
areas without having to create page breaks . Print preview will display all
these print areas in turn.

Do you mean I cannot more than one print area using VBA code ?

Regards
--
FLYNNE


"Tom Ogilvy" wrote:

There is only one print area per sheet. The behavior you describe is exactly
what I would expect.

The question is, what are you trying to accomplish with this?

Are you trying to do a print and have each table print out on a separate
sheet?

Perhaps a clearer explanation of what you hope to achieve will result in a
suggestion on how to approach the problem.

I wish to make all these tables individual print areas i.e end up with 365
print areas.


so you see that is not possible - but what funtionality are you trying to
achieve?



--
Regards,
Tom Ogilvy


"FLYNNE" wrote:

I have an Excel file in which a worksheet contains 365 identical tables
except for the date.

I wish to make all these tables individual print areas i.e end up with 365
print areas.

I wish to do this automatically using VBA code.

My only attempt to was use the following code on each table using a loop.

Sub PrintArea()

Application.ScreenUpdating = False

Worksheets("Sheet1").Activate

For t = 1 To 13141 Step 36

Range("A1")(t).Activate

ActiveSheet.PageSetup.PrintArea = ActiveCell.CurrentRegion.Address

Next t

Application.ScreenUpdating = True

End Sub

I used Step Into to view the operation of the code one line at a time.

Unfortunately as soon as the second table became a print area the first
table print area was deselected
As soon as the third table became a print area the second table print area
was deselected and so on.

The result of running the code was simply to make the last table a print
area.

Any suggestions please ?

I am quite willing to upload a copy of the file if this is at all possible.

--
FLYNNE

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
how do I print multiple print areas on one page Leo18 Excel Discussion (Misc queries) 1 January 11th 10 07:28 PM
Can I adjust print scaling for multiple print areas on the same sh N. Sammons Excel Discussion (Misc queries) 0 June 18th 08 10:24 PM
Need to print a workbook but worksheets have diff print areas Angela Steele Excel Discussion (Misc queries) 1 January 17th 08 07:39 PM
printing multiple print areas with a print dialog box LHaro Excel Programming 0 August 17th 05 09:56 PM
Multiple print areas, one worksheet -need to print to PDF! mohagany19 Excel Programming 0 October 6th 04 11:54 PM


All times are GMT +1. The time now is 09:06 PM.

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

About Us

"It's about Microsoft Excel"