I wish to create an auto number Returns Order template. I've never used VBA or MACROS in Excel before although I did do some basic stuff with MS Basic back in the DOS days. I wish to create a template consisting of 10 fields. I would like for each time the template is opened, an auto generated sequential number in cell B1. I would like the auto generated number to start 200001, and when the template has been filled, a print button that when clicked, will print 2 copies of the completed form, and auto save to a specific location, the filename same as auto generated number. I would also like the date to be automatically entered into cell B2. If this saved file is opened edited etc in the future, I need the auto number and date to not change. I've copied vba examples which say they will do what I want, but I must be doing something wrong, because I can't get any to work. I've created template and I've "view code" and selected "workbook" and pasted following code, but nothing happens!
Private Sub Workbook_Open() Const DEFAULTSTART As Integer = 1 Const MYAPPLICATION As String = "Excel" Const MYSECTION As String = "myInvoice" Const MYKEY As String = "myInvoiceKey" Const MYLOCATION As String = "A1" Dim regValue As Long With ThisWorkbook.Sheets(1).Range(MYLOCATION) If .Text <> "" Then Exit Sub regValue = GetSetting(MYAPPLICATION, MYSECTION, _ MYKEY, DEFAULTSTART) .Value = Format(date,"YY") & "-" & format(regValue,"00000") SaveSetting MYAPPLICATION, MYSECTION, MYKEY, regValue + 1 End With End Sub Am I pasting in the wrong place? Can anybody help. I've seen commercial options to achieve what I require, but I want to learn how to do it myself, as I have many other projects I could use this experience for. Regards enquirer -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/pages/discussexcelcom/160307843985936?v=wall&ref=ts