Auto Number

aswain

New Member
Joined
Jul 30, 2010
Messages
7
Have a Shipper Form created with an inventory cntrl # and I need that number to increment by 1 after I click the print function. Is this even possible ?
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
You'll need to provide more details. Is this on a userform or a worksheet. Where is the cntrl #?
 

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,454
Hi aswain, welcome to the board.
What do you mean by 'click the print function'?
Are you using your own routine (macro) to do the printing?
If so it would be easy to add a line to make it do that.

If not (or you just can't count on the users to always use your routine) then perhaps we could come up with something that'll work in the Workbook_BeforePrint event.
(Just guessing but I would think it's most easily done by incrementing your counter just before printing rather than after.... would that be an option for you?)
 

aswain

New Member
Joined
Jul 30, 2010
Messages
7
the inventory cntrl# is in cell H11 it is just a worksheet that everytime we open it, it needs to have the last number that was printed shown but when we hit print it then needs to increment by 1
 

aswain

New Member
Joined
Jul 30, 2010
Messages
7

ADVERTISEMENT

Here is how the workbook is layed out. First sheet is our shipper form second sheet is inventory reciept third sheet is a Discrepancy Form , but I only need the Shipper form to be able to change numbers after it is printed, do not want it to auto number until we hit print.
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Perhaps this in the ThisWorkbook module

Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Shipper" Then
    With Range("H11")
        .Value = .Value + 1
    End With
End If
End Sub
 

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,454

ADVERTISEMENT

Try using something like this in your ThisWorkbook module. (Change the sheet name or the A1 reference to your real needs.)
Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
With Sheets("Shipper")
  .Range("A1").Value = .Range("A1").Value + 1
End With
End Sub
Now, if the workbook gets saved before closing, it'll show the last number that was printed when it opens again.

Hope it helps.


[EDIT]
Yeah, check out Vog's idea because I didn't test for which sheet was getting printed so if that matters then... (well, there you go).
 
Last edited:

aswain

New Member
Joined
Jul 30, 2010
Messages
7
Thank You for all of your help, What / where is the workbook module ?
 

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Press ALT + F11 to open the Visual Basic Editor. Double click ThisWorkbook shown in the Project window.
 

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,454
(And then press Alt+Q to close the vbe after pasting your code.) ;)
 

Watch MrExcel Video

Forum statistics

Threads
1,133,158
Messages
5,657,162
Members
418,363
Latest member
Debating_Earth

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
Top