Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to create an automatic counter
Hi
I have created an excel file to log supplier concern, each concern need a unique reference number Example : 322 Each time i save the file or open the file, i'm saving the associated information, and next time i open again the file, i need the number to become : 323 automatically, so i do not dupplicate the info. Anybody can help? --- Message posted from http://www.ExcelForum.com/ |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to create an automatic counter
Hi
What you can do is add the following to your code Sub AutoNew( Order = System.PrivateProfileString("C:\Settings.Txt", "Macrosettings", "Order" If Order = "" The Order = Els Order = Order + End I System.PrivateProfileString("C:\Settings.Txt", "Macrosettings", "Order") = Orde ActiveDocument.Bookmarks("Order").Range.InsertBefo re Format(Order, "00#" End Su The first time te file settings.txt will be created. And every time you create a new file, the value = value + 1. Place the field in your document and you have your counter.. Good luck Marco. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to create an automatic counter
2 places to store the info: A cell in a (hidden?) worksheet or in th
Names. Range method: Sub WorkbookOpen thisworkbook.sheets(1).range("a1").value thisworkbook.sheets(1).range("a1").value+1 End Sub Names method Sub WorkbookOpen ThisWorkbook.Names(1).Name = "_" (FormatNumber(Right(ThisWorkbook.Names(1).Name Len(ThisWorkbook.Names(1).Name) - 1)) + 1) End Sub Dunca -- Message posted from http://www.ExcelForum.com |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to create an automatic counter
Hi Marco
I am interested in what you propose ..... Where is the object System.PrivateProfileString ? The code does not work for me. Cheers Nigel "Marco" wrote in message ... Hi, What you can do is add the following to your code: Sub AutoNew() Order = System.PrivateProfileString("C:\Settings.Txt", "Macrosettings", "Order") If Order = "" Then Order = 1 Else Order = Order + 1 End If System.PrivateProfileString("C:\Settings.Txt", "Macrosettings", "Order") = Order ActiveDocument.Bookmarks("Order").Range.InsertBefo re Format(Order, "00#") End Sub The first time te file settings.txt will be created. And every time you create a new file, the value = value + 1. Place the field in your document and you have your counter... Good luck! Marco. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to create an automatic counter
Hi Nigel
Just create a sub with the code, and in your macro use Call AutoNe There is no object needed. It's just a system command Regards Marco. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I set an automatic working days counter | Setting up and Configuration of Excel | |||
How do I create a counter? | Excel Discussion (Misc queries) | |||
create a counter | Excel Discussion (Misc queries) | |||
How do I create a counter for invoices, order numbers etc | New Users to Excel | |||
automatic counter or auto-increment | Excel Programming |