Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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
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 set an automatic working days counter Selekeng Setting up and Configuration of Excel 2 March 8th 07 03:28 PM
How do I create a counter? AG Excel Discussion (Misc queries) 1 May 24th 06 02:37 PM
create a counter sjl Excel Discussion (Misc queries) 1 April 26th 06 01:30 PM
How do I create a counter for invoices, order numbers etc nolanpatrick New Users to Excel 2 July 6th 05 12:58 AM
automatic counter or auto-increment Jjt Excel Programming 1 January 16th 04 07:56 PM


All times are GMT +1. The time now is 08:04 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"