LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Printing Macro

Form Print Macro

I was given a workbook in which Sheets 1-4 are forms and have formulas
referring to sheet 5 which contains the data. I had to update the forms for a
new FY format and now the macro crashes XL.

Sub Printer()
'
' Printer Macro
' Keyboard Shortcut: Ctrl+p
'
Sheets("ATTACHMENT A").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Cells.Replace What:="3", Replacement:="4", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Cells.Replace What:="4", Replacement:="5", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False
..
..
..
Sheets("ATTACHMENT B").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Cells.Replace What:="3", Replacement:="4", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Cells.Replace What:="4", Replacement:="5", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

The macro continues through the rest of the forms and rows

I want to optimize the code so it collates the forms together and if
possible send one print job to printer so I can use printer binging
functions. Also would like to do a test for last row in data so I dont have
to hardcode lines(but dont know how to achieve) Here is what I have but
cannot figure out where to go from here€¦ Please help

Sub Printer()

Dim org(3) As Integer 'starting row 3 for print
Dim nxt As Integer 'next row to print
Dim Count As Integer 'Counter

Application.ScreenUpdating = False

For Count = 1 To 34 €˜need to change to test for last row
nxt = org + 1
Sheets("SHEET1").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Cells.Replace What:=org, Replacement:=nxt, LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False
Sheets("SHEET2").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Cells.Replace What:=org, Replacement:=nxt, LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False
Sheets("SHEET3").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Cells.Replace What:=org, Replacement:=nxt, LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False
Sheets("SHEET4").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Cells.Replace What:=org, Replacement:=nxt, LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False
org = org + 1
Next Count

€˜need to reset back to 3

Application.ScreenUpdating = True


End Sub

 
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
Macro for printing PhillyD Excel Programming 2 February 6th 09 07:17 PM
Printing Macro how do I pano Excel Worksheet Functions 1 January 23rd 07 11:41 AM
printing using a macro John Excel Discussion (Misc queries) 1 June 14th 06 01:20 PM
Printing Macro kwedde01 Excel Worksheet Functions 0 June 9th 05 11:05 PM
Printing in a Macro Don Guillett[_4_] Excel Programming 0 August 8th 03 01:11 AM


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