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: 139
Default How to automatically change number of pages to print?

Husker87:

pasted the code into the Thisworkbook

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim r As Variant
r = VBA.Split(Range("A1"), "-")
If UBound(r) 0 Then
ActiveSheet.PrintOut From:=Val(r(0)), To:=Val(r(1))
Else
ActiveSheet.PrintOut From:=Val(r(0)), To:=Val(r(0))
End If
End Sub

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Husker87" wrote:

Thanks for the reply... I pasted the code into the worksheet, entered the
number 1 in "A1" and it still prints all 3 pages when I click my print icon.
Could the fact that I have defined a print range with in the worksheet affect
it?

"chijanzen" wrote:

Husker87:

enter the number of pages they want to print in cell A1


if You want print 2,3 pages, cell A1 is 2-3
if You want print only 2 pages, cell A1 is 2

e.g. print 2 and 3 pages

Range("A1")="2-3"
Dim r As Variant
r = VBA.Split(Range("A1"), "-")
If UBound(r) 0 Then
ActiveSheet.PrintOut From:=Val(r(0)), To:=Val(r(1))
Else
ActiveSheet.PrintOut From:=Val(r(0)), To:=Val(r(0))
End If



--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Husker87" wrote:

Here is the challenge I have a worksheet that prints 3 pages. Depending on
how much information is put into it I have users that may only need to print
out 1 or 2 pages. I know you can manually go in and select to print only the
number of pages you want but I was wondering if you can, for example, have
them enter the number of pages they want to print in cell A1 then click
print and the worksheet would only print that number of pages? Thanks. What
do you think?

 
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
Number of pages in worksheet doesn't match Print Preview pages delru Excel Discussion (Misc queries) 2 May 10th 10 10:08 PM
Print 100 pages with data change of each pahe tran1728 Excel Discussion (Misc queries) 0 December 7th 09 04:33 AM
need a print macro to print only a certain number of pages Tonso Excel Discussion (Misc queries) 2 July 26th 06 06:03 PM
Get number of pages to be printed - before print Les Stout[_2_] Excel Programming 8 October 27th 05 05:17 PM
To number/print pages 71paolo71[_2_] Excel Programming 1 May 5th 04 12:54 AM


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