Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Printing Problems

Hi

I have a printing problem. I Have a workbook that has many worksheeets,
each containing data of different sizes.
I want users to be able to choose the Dates i.e startDate and stopDate
which run along row 6 on every worsheet.
Also the code finds the end row of every sheet.
The code I have written works the first time round a loop but when it gets
to the next sheet it prints the whole sheet not just the data selected by
the user.
Here is the code I really would be grateful for any help on this macro.

Sub PrintBigBook()

Dim startDate As String
Dim stopDate As String
Dim startCol As Integer
Dim stopCol As Integer
Dim rowNum As Range
Dim lastRow As Long
Dim Ws As Worksheet


Sheets("Management Summary").Activate

startDate = InputBox("Enter the Beginning Date: (dd/mm/yy)")
If startDate = "" Then End
stopDate = InputBox("Enter the End Date: (dd/mm/yy)")
If stopDate = "" Then End

For Each Ws In Worksheets
startCol = Ws.Rows(6).Find(startDate, _
LookIn:=xlValues, lookat:=xlWhole).Column
stopCol = Ws.Rows(6).Find(stopDate, _
LookIn:=xlValues, lookat:=xlWhole).Column

Set rowNum = Ws.Range("A1").SpecialCells(xlCellTypeLastCell)
lastRow = rowNum.Row

On Error Resume Next
Ws.Names.Add "Print_Area", Ws.Range(Cells(6, startCol), Cells(lastRow,
stopCol))
Ws.PrintOut Copies:=1

Next Ws

End Sub



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Printing Problems

I think you will have to set your print area by modifying the usual
ws.PageSetup.PrintArea = "$A$1:$C$3"
to something like
ws.PageSetup.PrintArea = _
Ws.Range(Cells(6, startCol), Cells(lastRow,stopCol)).address

--
Don Guillett
SalesAid Software

"Subs" wrote in message
...
Hi

I have a printing problem. I Have a workbook that has many worksheeets,
each containing data of different sizes.
I want users to be able to choose the Dates i.e startDate and stopDate
which run along row 6 on every worsheet.
Also the code finds the end row of every sheet.
The code I have written works the first time round a loop but when it gets
to the next sheet it prints the whole sheet not just the data selected by
the user.
Here is the code I really would be grateful for any help on this macro.

Sub PrintBigBook()

Dim startDate As String
Dim stopDate As String
Dim startCol As Integer
Dim stopCol As Integer
Dim rowNum As Range
Dim lastRow As Long
Dim Ws As Worksheet


Sheets("Management Summary").Activate

startDate = InputBox("Enter the Beginning Date: (dd/mm/yy)")
If startDate = "" Then End
stopDate = InputBox("Enter the End Date: (dd/mm/yy)")
If stopDate = "" Then End

For Each Ws In Worksheets
startCol = Ws.Rows(6).Find(startDate, _
LookIn:=xlValues, lookat:=xlWhole).Column
stopCol = Ws.Rows(6).Find(stopDate, _
LookIn:=xlValues, lookat:=xlWhole).Column

Set rowNum = Ws.Range("A1").SpecialCells(xlCellTypeLastCell)
lastRow = rowNum.Row

On Error Resume Next
Ws.Names.Add "Print_Area", Ws.Range(Cells(6, startCol), Cells(lastRow,
stopCol))
Ws.PrintOut Copies:=1

Next Ws

End Sub





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 problems Kim2900 Charts and Charting in Excel 3 December 2nd 09 02:31 PM
Printing Problems Janey Excel Discussion (Misc queries) 2 August 20th 07 10:44 PM
Printing problems Bigredno8 Excel Discussion (Misc queries) 4 April 9th 06 04:06 AM
Help with printing problems? C. P. Excel Discussion (Misc queries) 3 February 22nd 05 02:55 AM
Printing problems William Maka Excel Programming 0 February 4th 04 06:29 PM


All times are GMT +1. The time now is 06:01 AM.

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"