![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Join Date: Apr 2002
Posts: 52
|
is there any way in my macro to add one to a number. What i want to do is create my own invoice numbers. So when I get done with an invoice I can start a new invoice with a new invoice number automatically.
|
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Apr 2002
Posts: 112
|
Have you considered using a workbook as a log? Each column could be a field from the invoice, including the invoice number. When you created a new invoice, the macro would go down the invoice column and then find the last invoice number. I don't think that would be too difficult....
|
|
|
|
|
|
#3 |
|
Join Date: Apr 2002
Posts: 52
|
how?
|
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Apr 2002
Posts: 112
|
When you ask "how?", do you mean how do you have the macro find the next number? If so, you could have the macro start at the top of the invoice column and then do a end(xlDown) to find the end of the data in that column. The number in that cell would be the last invoice (assuming the page is sorted by invoice number) and your next invoice would be that number + 1. Do you have a worksheet as a log?
|
|
|
|
|
|
#5 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
If A1 has your number and you want B1 to equal A1 + 1 use the following code
Code:
[b1] = [a1] + 1 |
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Feb 2002
Posts: 3,064
|
Im a finance guy on sale ledger.. this is my ground and no one has really come up with a workable solution if the company dont run finance packsge thats doing this so excel to the rescue..
YES it can be done but its a build brick by brick task do you have the invoice template. do you have table of addresses to ie debtor address list so we can use this to produce the inmvoice. do you have stock or servoice sheet so we can charge the customer. these are the 3 MUST then we can move on or its pointless.
__________________
Free Excel based Web Toolbar available here. Jack in the UK J & R Excel Solutions "making Excel work for you" |
|
|
|
|
|
#7 |
|
Join Date: Apr 2002
Posts: 52
|
I am using a basic worksheet. I should say we are doing invoices one at a time where we enter the info, print, hit a macro to log into another worksheet, then enter the info again on the invoice. Cumbersome, yes, but we dont do many this way. And since we dont do many we want to be able to press the macro button and have the new invoice number set so when we come back to it we don't have to look up any old invoices. I apologize for the confusion-suggestions? thanks
|
|
|
|
|
|
#8 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
|
Hi,
Assume that your data is logged in sheet2 and the existing invoice numbers are in column A. When the invoice is loaded and the form is reset, would setting the invoice cell to =MAX(Sheet2!A:A)+1 work for you? If it is in VBA, you can do the same thing very easily. Sub test() Dim InvoiceNumber As Long InvoiceNumber = WorksheetFunction.Max(Sheets("Sheet2").Range("A:A")) + 1 MsgBox InvoiceNumber End Sub Bye, Jay |
|
|
|
|
|
#9 |
|
Join Date: Apr 2002
Posts: 52
|
just thought of something-is there a way to set up a macro or formula to generate a number? sequentially?
just a thought. |
|
|
|
|
|
#10 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Not sure I'm following, but if you want a separate worksheet for every invoice
Code:
Sub Invoicer() n = [a1].Value + 1 ActiveSheet.Copy after:=ActiveSheet ActiveSheet.Name = "Invoice_" & n [a1] = n End Sub Code:
[a7].clearcontents |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|