#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 112
Default Printing Help

Hi,
I'm new to excel and have created a spreadsheet with a dropdown list in the
first column. I had a problem printing because it would print the pages even
if there wasn't any text. I either got the following code from this site or
from the contextures website. It limits the pages printed but now it always
prints out one extra page. I need it to print only the page with text. It
will be a controlled document so having it say "2 of 2" when there isn't a
2nd page is unacceptable. I'm wondering if the code can be changed so it
prints only the page with text. I'm not familar with Excel VBA code (I work
mainly in Word and am quite proficient with Word VBA code). Any help will be
greatly appreciated.
Here's the code:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
With ActiveSheet
lr = .Cells(.Rows.Count, "a").End(xlUp).Row
For r = lr To 1 Step -1
If Application.CountA(.Rows(r)) 1 Then mr = .Rows(r).Row: Exit For
Next r
..PageSetup.PrintArea = .Rows("1:" & mr).Address
'or to limit columns
'.PageSetup.PrintArea = .Range("a2:x" & mr).Address
End With
End Sub

Thanks,
Mickey

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
Printing a heading on each new page when printing Brian Excel Discussion (Misc queries) 3 November 15th 06 06:22 PM
Printing nunoeca Excel Discussion (Misc queries) 1 August 13th 05 01:29 AM
printing sammy Excel Discussion (Misc queries) 2 April 12th 05 09:32 PM
Enable Double sided printing contiuously when printing multiple s. Lee Excel Discussion (Misc queries) 1 November 27th 04 02:58 AM
Printing Thad Excel Worksheet Functions 1 November 20th 04 11:31 AM


All times are GMT +1. The time now is 07:00 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"