Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Cathy Landry
 
Posts: n/a
Default how to auto assign po numbers in Excel

I have a po form in Excel and want to be able to auto assign the po number,
so that when this form is filled out and faxed/emailed in that number will
not change.

I know very little about macros.
  #2   Report Post  
Larry E
 
Posts: n/a
Default

Try this VB code

Private Sub Workbook_Open()
Dim FName As String
Dim FNo As String
Dim x As Long
FName = ThisWorkbook.Path & Application.PathSeparator & "Number.Txt"
FNo = FreeFile
x = 0
On Error Resume Next
Open FName For Input As #FNo
Input #FNo, x
x = x + 1
' *** Change range reference to suit ***
Range("K1").Value = x
Close #FNo
FNo = FreeFile
Open FName For Output As #FNo
Write #1, x
Close #FNo
End Sub

It should go in the ThisWorkbook module which can be accesed by right
clicking on the icon next to File in the main toolbar and selecting View Code.

Hope this helps. This code is thanks to the wonderful folks at the "Mr.
Excel" message board.

Larry

"Cathy Landry" wrote:

I have a po form in Excel and want to be able to auto assign the po number,
so that when this form is filled out and faxed/emailed in that number will
not change.

I know very little about macros.

  #3   Report Post  
Cathy Landry
 
Posts: n/a
Default

Thank you!! I will try this out.

"Larry E" wrote:

Try this VB code

Private Sub Workbook_Open()
Dim FName As String
Dim FNo As String
Dim x As Long
FName = ThisWorkbook.Path & Application.PathSeparator & "Number.Txt"
FNo = FreeFile
x = 0
On Error Resume Next
Open FName For Input As #FNo
Input #FNo, x
x = x + 1
' *** Change range reference to suit ***
Range("K1").Value = x
Close #FNo
FNo = FreeFile
Open FName For Output As #FNo
Write #1, x
Close #FNo
End Sub

It should go in the ThisWorkbook module which can be accesed by right
clicking on the icon next to File in the main toolbar and selecting View Code.

Hope this helps. This code is thanks to the wonderful folks at the "Mr.
Excel" message board.

Larry

"Cathy Landry" wrote:

I have a po form in Excel and want to be able to auto assign the po number,
so that when this form is filled out and faxed/emailed in that number will
not change.

I know very little about macros.

Reply
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
How do I assign sequential numbers in an Excel 2003 PO template? skiusa Excel Worksheet Functions 1 March 28th 05 10:57 PM
In Excel, I want to have all telephone numbers display in the sam. Fluffy from Wisconsin Excel Worksheet Functions 7 March 18th 05 02:05 AM
Excel countif based on size of numbers in one column in Access Kristjan_Thor Excel Worksheet Functions 3 March 17th 05 10:21 PM
Numbers after decimal point excel to word mail merge Andy P Excel Worksheet Functions 1 March 15th 05 11:48 AM
how do i set up to auto detect duplicated numbers in an excel fiel Peabody Excel Discussion (Misc queries) 1 December 15th 04 08:01 AM


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