M
ml123
I have used the following steps to automatically populate the PO number field
in a Purchase Order file, based on a template, with an incremental number .
It works perfectly!!
1. Create a folder called Base Data and within it create a file called
PONumber.xls
2. Type the next new PO number in cell A1 of Sheet1.
3. Press Alt+F11 and double click on the "This Workbook" node for
PONumber.xls. (Make sure it says "PONumber -[ThisWookbook (Code)]" in the
title bar.)
4. Copy and paste in the following code
Private Sub Workbook_Open()
Sheets("Sheet1").Select
Dim number
number = Range("A1").Value
number = number + 1
Range("A1").Value = number
Range("A1").Select
End Sub
5. Save and close this file.
6. Open your PO template file and in the cell where you want the number to
appear type this formula:
='C:\Base Data\[PONumber.xls]Sheet1'!$A$1
in the cell where you want the number to appear.
7. Press Alt +F11 and double click on the "ThisWorkbook" node for your
template (check the title bar) then copy and paste in the following code:
Private Sub Workbook_Open()
Application.ScreenUpdating = False
Workbooks.Open Filename:="C:\Base Data\PONumber.xls"
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.ScreenUpdating = True
End Sub
8. Save the template
HOWEVER, whenever I later open the saved populated Purchase Order the
numbers is changed. For examplte, if when the file was populated the PO
number was "PO0115" and a number of new POs have been saved since the
original file was created, when I open file "PO0115" it's PO number on screen
changes to the next new number held in my PONumber file e.g. "PO0119". How
do I stop this?
in a Purchase Order file, based on a template, with an incremental number .
It works perfectly!!
1. Create a folder called Base Data and within it create a file called
PONumber.xls
2. Type the next new PO number in cell A1 of Sheet1.
3. Press Alt+F11 and double click on the "This Workbook" node for
PONumber.xls. (Make sure it says "PONumber -[ThisWookbook (Code)]" in the
title bar.)
4. Copy and paste in the following code
Private Sub Workbook_Open()
Sheets("Sheet1").Select
Dim number
number = Range("A1").Value
number = number + 1
Range("A1").Value = number
Range("A1").Select
End Sub
5. Save and close this file.
6. Open your PO template file and in the cell where you want the number to
appear type this formula:
='C:\Base Data\[PONumber.xls]Sheet1'!$A$1
in the cell where you want the number to appear.
7. Press Alt +F11 and double click on the "ThisWorkbook" node for your
template (check the title bar) then copy and paste in the following code:
Private Sub Workbook_Open()
Application.ScreenUpdating = False
Workbooks.Open Filename:="C:\Base Data\PONumber.xls"
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.ScreenUpdating = True
End Sub
8. Save the template
HOWEVER, whenever I later open the saved populated Purchase Order the
numbers is changed. For examplte, if when the file was populated the PO
number was "PO0115" and a number of new POs have been saved since the
original file was created, when I open file "PO0115" it's PO number on screen
changes to the next new number held in my PONumber file e.g. "PO0119". How
do I stop this?