Print Macro Help

aywest

New Member
Joined
Aug 15, 2011
Messages
4
I would like to create a macro that does the following:

Run the macro, it asks me how many pages I would like to print: I enter the integer number. Then it prints the work form.

However;

When it prints I want it to increment the value in cell M1 by +1 each time it prints a sheet out. For example: If I print 5 sheets it will come out 1, 2, 3 , 4 , and 5 (assuming the value in cell M1 is 1 at the time).

Any help writing this would be amazing.

Thank you,

aywest
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Try like this

Code:
Sub prt()
Dim n As Long, i As Long
n = Application.InputBox("How many copies", Type:=1)
With Sheets("work")
    For i = 1 To n
        .Range("M1").Value = i
        .PrintOut
    Next i
End With
End Sub
 
Upvote 0
Welcome to the forum,

Here is some sample code to fulfill your needs

Sub PrintCopies1()

Dim CopiesCount As Long
Dim CopieNumber As Long
CopiesCount = Application.InputBox("How many copies do you want", Type:=1)

For CopieNumber = 1 To CopiesCount
With ActiveSheet
' This example print the number in cell A1
.Range("M1").Value = CopieNumber & " of " & CopiesCount

'If you want the number in the footer use this line
'.PageSetup.LeftFooter = CopieNumber & " of " & CopiesCount

'Print the sheet
.PrintOut
End With
Next CopieNumber
End Sub
 
Upvote 0
Thank you for all the help.

Trevor your macro works perfectly; however, is there a line a code I can remove so it doesn't print the 1 of 3, 2 of 3, and 3 of 3? I just want it to print for example:

M1 cell value=1000
I want to print 10 times.
What is printed is:
1001, 1002, 1003, 1004...1008, 1009, 1010

VoG, when I run yours I get an error to debug it and it tells me that the With Sheets("work")
line of code is buggy. I'm too new with macros to know how to begin to fix this.

Any help is much appreciate....from a very girly n00b.
 
Upvote 0
After days of the print macro working I'm experiencing issues with it. I'm not seeing any changes. My excel crashed and I'm wondering if I corrupted it some how. I'm not getting a run error or anything, it just won't print via the macro. >_<

Sub prt()
Dim n As Long, i As Long
n = Application.InputBox("How many copies", Type:=1)
With Sheets("STDMech")
For i = 1 To n
.Range("M1").Value = i
.PrintOut
Next i
End With
End Sub


-----------------------------------

Just to reiterate what I want. I'm doing work orders for a mechanical shop. Every time I need new work orders I need to keep the sequence of the numbers going. I found that 1 To n will only ever print 1-how ever many copies I print, so I have been changing the value of one to reflect the work order number I am on now. For ex. 15 To n (so when I print 10 more copies i will get, 15, 16, 17, etc....) Now it's not working.

Any hints or suggestions? This macro is kicking my butt. Doesn't help that the computer at work is very slow and whenever I make it over think it crashes Excel >_<*
 
Upvote 0
Place your sub routine in new workbook with some simple data in it and see if you can run the sub routine, if it works it might be the workbook, if it fails check out the security levels you have on your Excel.
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top