LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
Alec H
 
Posts: n/a
Default Repeat form printing with new data by macro


Hi,

Slightly more complex one this time.......

I have a workbook with 4 worksheets titled as follows..

"Stage 1 - Visit diary" - relevant range E4:E58

"Stage 1 - Visit form"

"Formulas" - Relevant range P5:P59

"Customer List" - relevant range Column A

I have written a macro that does the following,

1. Copies the user selected (by filter) records from the "Customer
list" worksheet.
2. Pastes the above records into the "Formulas" worksheet and then
sorts alphabetically.
3. Copies the sorted records and pastes into the "Stage 1 - Visit
diary" worksheet.
4. Copies the first 3 records from step 3 into the "Stage 1 - Visit
form" worksheet (3 records per page) and prints it.
5. Goes back to the "Stage 1 - Visit diary" sheet and repeats step 4
with the NEXT 3 records if they exist (and ends the macro if they
dont).

Step 5 is where it is all going wrong.......Currently it only prints
the first 3 records (1 page) then finishes the macro regardless if
there are further records or not.


This is my code..

' Cut and paste filtered customers and sort alphabetically

ActiveSheet.Columns("A:A").Select
Selection.Copy
Sheets("Formulas").Select
Range("P5").Select
ActiveSheet.Paste
Range("R5:R60").Select
Rows("5:60").Select
Range("F5").Activate
Selection.Sort Key1:=Range("R5"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

' Select, sort and print page 1

Range("P5:P7").Select
Selection.Copy
Sheets("Stage 1 - Visit diary").Select
Range("E4").Select
ActiveSheet.Paste
Sheets("Stage 1 - Visit form").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

' Select, sort and print page 2

Sheets("Formulas").Select
If ("P8" < 1) Then GoTo SKIP
Range("P8:P10").Select
Selection.Copy
Sheets("Stage 1 - Visit diary").Select
Range("E4").Select
ActiveSheet.Paste
Sheets("Stage 1 - Visit form").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

' Return to customer list

SKIP: Sheets("Customer List").Select

End Sub

Help..........


--
Alec H
------------------------------------------------------------------------
Alec H's Profile: http://www.excelforum.com/member.php...o&userid=31042
View this thread: http://www.excelforum.com/showthread...hreadid=515306

 
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
Editing a simple macro Connie Martin Excel Worksheet Functions 5 November 29th 05 09:19 PM
Macro Help In Excel welshlad Excel Discussion (Misc queries) 14 October 26th 05 02:34 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
Macro data selection line delete Frantic Excel-er Excel Discussion (Misc queries) 0 May 31st 05 11:46 PM
format cell from data input to output form Brad Stevenson Excel Worksheet Functions 2 May 19th 05 06:04 PM


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