How do you auto number sequence in a macro

R

Rob

I have a template for my invoices in Excel 2002, i would
like each new invoice automatically go to the next number
in sequence.What is the process to do this? Thank you.
 
S

Steve Lang

Hi Rob,

The easiest way to do this is with an external text or ini file that would
keep track of the values.

HTH and have a great day!

Steve Lang
 
R

Rob

-----Original Message-----
Hi Rob,

The easiest way to do this is with an external text or ini file that would
keep track of the values.

HTH and have a great day!

Steve Lang

Hi Steve, do you know the process and how i can do that.

Thanks for your help.
Rob
 
S

Steve Lang

Hi Rob,

This code will open a file, grab the value in the file, store it in a
variable, increment it by one, and save it back to the file.

Sub ReadWriteTextFromFile()

Dim FileNumber As String
Dim strCount As String
Const cFile = "C:\Test\TextFile.txt"

'Read from file
FileNumber = FreeFile()
Open cFile For Input As #FileNumber
Input #FileNumber, strCount 'this puts the value found in the text file into
the variable strCount
Close #FileNumber ' Close file.
strCount = CStr(CInt(strCount) + 1) 'increment the counter
'Replace the file with the new value
Kill cFile
'create new file with new value
FileNumber = FreeFile()
Open cFile For Append As #FileNumber
Print #FileNumber, strCount 'write the new value to the file
Close #FileNumber ' Close file.
End Sub
 
G

Guest

-----Original Message-----
Hi Rob,

This code will open a file, grab the value in the file, store it in a
variable, increment it by one, and save it back to the file.

Sub ReadWriteTextFromFile()

Dim FileNumber As String
Dim strCount As String
Const cFile = "C:\Test\TextFile.txt"

'Read from file
FileNumber = FreeFile()
Open cFile For Input As #FileNumber
Input #FileNumber, strCount 'this puts the value found in the text file into
the variable strCount
Close #FileNumber ' Close file.
strCount = CStr(CInt(strCount) + 1) 'increment the counter
'Replace the file with the new value
Kill cFile
'create new file with new value
FileNumber = FreeFile()
Open cFile For Append As #FileNumber
Print #FileNumber, strCount 'write the new value to the file
Close #FileNumber ' Close file.
End Sub

Steve, i'm sorry... i am Excel illiterate!! What i need
is the TOTAL step by step process to do ALL of this.
What happens right now, from an earlier attempt, when i
open the invoice..." disable macros/ enable macros/ more
info" comes up...when i open either disable or enable
macros, the invoice comes up and the number of the invoice
is there in column D27. Is there any more info you need
from me? I'd appreciate your help....Thank you.
 
R

Rob

-----Original Message-----
in
the text file into
is the TOTAL step by step process to do ALL of this.
What happens right now, from an earlier attempt, when i
open the invoice..." disable macros/ enable macros/ more
info" comes up...when i open either disable or enable
macros, the invoice comes up and the number of the invoice
is there in column D27. Is there any more info you need
from me? I'd appreciate your help....Thank you.
need
is the TOTAL step by step process to do ALL of this.
What happens right now, from an earlier attempt, when i
open the invoice..." disable macros/ enable macros/ more
info" comes up...when i open either disable or enable
macros, the invoice comes up and the number of the invoice
is there in column D27. Is there any more info you need
from me? I'd appreciate your help....Thank you.
 
S

Steve Lang

Hi Rob,

What I need is your bank account number! LOL! I really can't take the time
to do your coding for you unless you are willing to pay for it. On the other
hand, I'll be happy to assist with pointing you in the right direction, or
giving specific tips on how to accomplish specific actions, but I (and I
don't think anyone else in the NG) has the time to do your coding for you,
start to finish.

Crack open the books and start coding. When you have specific questions,
drop back in...

Steve
 
R

Rob

-----Original Message-----
Hi Rob,

What I need is your bank account number! LOL! I really can't take the time
to do your coding for you unless you are willing to pay for it. On the other
hand, I'll be happy to assist with pointing you in the right direction, or
giving specific tips on how to accomplish specific actions, but I (and I
don't think anyone else in the NG) has the time to do your coding for you,
start to finish.

Crack open the books and start coding. When you have specific questions,
drop back in...

Steve



Hey Steve, thanks anyway, i'll keep my bank account
intact! :) Someone has given me the process and the code
at no charge!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top