View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.newusers
JLatham JLatham is offline
external usenet poster
 
Posts: 3,365
Default From Template Save As Help

Bob - to explain. First must determine which of 3 possible workbooks she's
talking about. One was developed in a long thread elsewhere and uses an
external .txt file to contain the last invoice number used. Two others use a
Name to keep the number internal to the file. Earlier versions had the code
updating the invoice number entry every time the file was opened - that was
from original code obtained from another site.
I've modified the code in that one, and set up code in the two other
versions to never insert an invoice number into a cell with an invoice number
already in it.

Consider the version with the external .txt file tracking last used invoice
number: you open the template file, it pops the next invoice number into the
proper cell. You open that same file again, the code will not do that
because it will see there is already an invoice number in it.

In the case of the one with the invoice number kept internally, there is a
"template" sheet that has no entry in the invoice number cell - the code in
the sheet's Activate event tries to put a number in it UNLESS:
there's already a number in it, OR
if the sheet name is the template sheet's name.
There is a button on the sheet to create new invoice which simply copies the
'template' sheet which in turn activates the new sheet, which automatically
assigns that new sheet the next invoice number in sequence.

All that's left to be decided, as far as I know, is which one of the two
PammiJ feels will work best with the way they do the work at their
establishment.



"Bob Phillips" wrote:

Have your code in a master workbook, with an invoice template worksheet
within it. Then copy that template to a new workbook, like so

ThisWorkbook.Worksheets("Template").Copy
With ActiveWorkbook
'your code
End With

just make sure that all of the code works on the actoive workbook from that
point on.

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"Pammi J" wrote in message
...
Hi
i have a invoice template and with the help of JLatham i have managed to
get
the invoice number to increment by one each time i open it. BUT i have a
big
problem when i have filled out the invoice with customer details and the
invoice number iss example 100 and then `save as` (cust name and no) it
seems
to be carrying the macro with it - so when i open cust name inv 100 it
becomes 101 - and then i open template that becomes 102 and so on.
I need it to save as per the village software invoice - saves just a copy
to
wherever i specify so if i need to reopen that copy it doesnt change the
invoice number.
Any help much appriciated