FocIS
asked on
incremental printing in excel 2010
Hello,
I'm trying to print X number of pages with incrementing numbers in TWO cells per page.
Using the code below, i can easily increment one cell per printed page, but i need two.
Example:
page 1 should have increments 1 and 2
page 2 should have increments 3 and 4
and so on.
In my testing to this point, i can get page 1 with increments 1 and 2, but page two would have increments 2 and 3, then page three would have increments 3 and 4...
The important cells in Sheet1 are:
B8 = should be the first increment per page
B20 = should be the second increment per page
M11 = user defined number of pages to print
code i have so far follows
also, when i set B20 to "=B8+1" it doesn't seem to matter because B8 is always sequentially 1..2..3...4..5...
I'm trying to print X number of pages with incrementing numbers in TWO cells per page.
Using the code below, i can easily increment one cell per printed page, but i need two.
Example:
page 1 should have increments 1 and 2
page 2 should have increments 3 and 4
and so on.
In my testing to this point, i can get page 1 with increments 1 and 2, but page two would have increments 2 and 3, then page three would have increments 3 and 4...
The important cells in Sheet1 are:
B8 = should be the first increment per page
B20 = should be the second increment per page
M11 = user defined number of pages to print
code i have so far follows
also, when i set B20 to "=B8+1" it doesn't seem to matter because B8 is always sequentially 1..2..3...4..5...
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim i As Long
Cancel = True
Application.EnableEvents = False
Application.Dialogs(xlDialogPrinterSetup).Show
With Sheets("Sheet1")
For i = 1 To .Range("M11").Value
.Range("B8").Value = .Range("B8").Value + 1
.Range("B20").Value = .Range("B8").Value + 2 'playing with this line to see what happens
.PrintOut
Next i
End With
Application.EnableEvents = True
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This is exactly what i needed
The final code i used is:
The final code i used is:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim i As Long
Cancel = True
Application.EnableEvents = False
Application.Dialogs(xlDialogPrinterSetup).Show
With Sheets("Sheet1")
For i = 1 To .Range("M11").Value Step 2
.Range("B8").Value = i
.Range("B20").Value = .Range("B8").Value + 1
Application.Calculate
DoEvents
.PrintOut
Next i
End With
Application.EnableEvents = True
End Sub
Okay Great... Always Happy to help.. :-)
Saurabh...
Saurabh...
ASKER
Just a follow up to this, and i can open a new question with points to reward if necessary but... based on the code above here's what the end user experiences
choosing to print 50 pages, the printer actually outputs in a random order
so they might get on paper in this order:
1+2
3-10
15-20
11-14
31-36
21-30
31-50
is there anything i can add in there to ensure each print job goes in order?
maybe a delay would do it, or something more specific?
choosing to print 50 pages, the printer actually outputs in a random order
so they might get on paper in this order:
1+2
3-10
15-20
11-14
31-36
21-30
31-50
is there anything i can add in there to ensure each print job goes in order?
maybe a delay would do it, or something more specific?
Sure feel free to do so and if you can explain what exactly you are looking for. I can help you write the code for it..
Saurabh...
Saurabh...
ASKER
posted a new question for this follow-up:
https://www.experts-exchange.com/questions/28888940/Follow-up-Q-to-incremental-printing-in-excel.html
https://www.experts-exchange.com/questions/28888940/Follow-up-Q-to-incremental-printing-in-excel.html
ASKER
a. make the increment FOR loop count by two's (so the resulting math for B20 works)
b. set B20 = "B8+1" and make sure B20 has a chance to update before the print function
c. nest some more FOR loops between printing, that variable starting at one more than "i"