VBA Code To Check That Invoice Number Has Not Already Been Used
Nov 2, 2011
I use a userform to make sales data entries into a database. The userform contains textboxes for:
Invoice No.Invoice DateGrossVatNet The Invoice No. is the first entry box on the userform and it is important that users enter the correct format (which is alphanumeric).
It is also important that a checking is carried out to ensure that the Invoice Number being entered has not already been used.
I use the following code to ensure that the numbers are entered in the desired format:
Code:
Private Sub txtInv_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If txtInv.Value = vbNullString Then Exit Sub
If (Not UCase(Me.txtInv.Value) Like "ST###") And (Not UCase(Me.txtInv.Value) Like "ST####") Then
MsgBox "Non Valid Invoice Number.”
Cancel = True
End If
End Sub
And this code is pasted lower down the VB editor window. And it seems to be working fine!
For the checking to ensure that the invoice number being typed into the textbox has not already been used, I use the following two codes combined together:
a) to check for invoice No.:
Code:
check for Invoice Number
If Trim(Me.txtInv.Value) = "" Then
Me.txtInv.SetFocus
MsgBox "Please Enter Invoice No."
Exit Sub
End If
b) And to it I add the following additional code for CHECKING that the no. does not already exist in the database (the invoice nos are located in Column A of the database):
Code:
Dim x
X= Application.Match(Me.txtInv.Value, Columns(1),0)
If Not IsError(x) Then
MsgBox Me.txtInv.Value & "Invoice Number Is Already Used"
Me.txtInv.SetFocus
Cancel = True
Exit Sub
End If
My problem with the second set of codes in (a) & (b) (for the Checking of already existing No.) is that the code allows the user to key in the Invoice No. and go through filling in the other textboxes. It is only after clicking the ‘Add’ button that a msgbox comes up to indicate that the ‘invoice no. is already used’.
I need a tweaking of the codes so that the moment an invoice no. that has already been used is typed into the textbox and the TAB button pressed, a msgbox will show up at that stage to indicate that the ‘Invoice no. is already used’. This will reduce time and avoid filling in the other textboxes and clicking the ‘Add’ button before the checking is done.
View 3 Replies
ADVERTISEMENT
Oct 30, 2008
I have an Excel Invoice Template, saved as a template.
I have code that generates a new invoice number each time the template is opened in VBA Editor. The auto numbering system works great! However.... (here comes the sad part)
After I enter all the data I need on the invoice, I want to save a copy of the invoice in a different file folder, which I can no problem. The problem is, if I re-open the saved invoice, we will call it Invoice #100, excel asks me if I want to update, if I say either yes or no, the invoice number will change to Invoice #101. I'm sure you can see how this can cause a major problem if we need to compare information later on, finding the correct invoice would be almost impossible as it would not match the customers invoice number.
What I need to know is:
Is there code I can add to the existing code, to stop the increment on a saved invoice, but not on the original template?
View 9 Replies
View Related
Sep 8, 2009
Data Table including-
List of Identifying Code Numbers for customer invoices
Multiple repetitions of individual Identifying Code Numbers in list
Various data in table range including Various Values of invoices from different dates for each repetion of Identifying Code Number.
- Wish to find largest invoice for each Individual Identifying Code Number in the table without using a pivot table.
i have tried combining Max and Large functions with Vlookups etc.
View 9 Replies
View Related
Mar 12, 2014
The following code displays the message box and loads a userform if the Active cell offset 1, -1 when within G column equals "LAST ROW".
[Code] .....
How can I change it so instead it performs those same actions (displaying the message box, and loads the userform) if the number of rows between the last data entry in G and the last data entry in F is equal to 0?
View 3 Replies
View Related
Oct 3, 2013
I'm Trying to create a invoice that generates the invoice number automatically every time its being opened
Now, how to do it with a macro but the problem is i need the invoice to be saved as a template. In the end i need the invoice template to move the invoice number to the next one when opened and when im done with the invoice i need a print button that saves the invoice with contents to a specific folder, clears the contents and saves the invoice with the current invoice number as a template so that next time its being opened it can just adjust the counter.I have done the counter adjustment part .
View 1 Replies
View Related
Apr 13, 2009
Leith got this perfect for me, but my example does not work right. Not sure why it does not save last invoice number too the workbook. The invoice number increase works great, I must be missing a step.
View 3 Replies
View Related
Jan 28, 2010
My problem is that I have a worksheet tab (RawTimeSheetData) which contains a whole series of week/timecode values for a range of people.
I want to accumulate the hours for an invoice period / job code combination. As an example in the tab InvoicePeriodSummaryTimes cell D6 i want to sum all the hours from RawTimeSheetData where both cells A6 & B6 from InvoicePeriod tab = cells D6 & E6 from the rawdata tab.
View 6 Replies
View Related
Jan 21, 2007
I've created an Invoice Template in excel. Each time I open it I'd like a certian cell "D3" to increase by one number starting at 2000. Each time this is opened a new customer information is input and then saved to their file. Please give me the very basicis on how to do this. I've already gone into other forums which have provided a code, but I have had any luck getting ti too work.
View 9 Replies
View Related
Mar 15, 2005
I created an receipt template in excel. How can I have it increase the receipt invoice number by 1 every time I open this template? For example the first receipt is 100, I want the second receipt to be 101, and so on.
View 4 Replies
View Related
Jun 27, 2006
I am trying to automatically show the date of the last invoice per the customer number.
I have attached an example.
View 9 Replies
View Related
Jan 21, 2007
I've created an Invoice Template in excel. Each time I open it I'd like a certian cell "D3" to increase by one number starting at 2000. Each time this is opened a new customer information is input and then saved to their file. Please give me the very basicis on how to do this. I've already gone into other forums which have provided a code, but I have had any luck getting ti too work.
View 9 Replies
View Related
Aug 21, 2007
I have created a templet for an invoice, but I cannot get the invoice number to increment. I am using the following code from a previous thread
Private Sub Workbook_Open()
Sheets("Sales Invoice"). Range("B7").Value = Sheets("Sales Invoice").Range("B&").Value + 1
End Sub
The address of the invoice number is B7 and the name of the sheet where the B7 is located is Sales Invoice.
I want to start the invoice number at 100000 and add the letters PM to the beginning so that when it is displayed and printed out it reads PM100000.
Then I want it to increment by 1 and this number be placed in the B7 area when the invoice is opened next time.
View 9 Replies
View Related
Jan 22, 2013
I have a template invoice in excel. What I want is a macro code that when it is run the open template invoice should be sent to a specific email address !!
View 5 Replies
View Related
Oct 22, 2008
I have recorded a macro to filter data on sheet 'To Invoice' copy the filtered list, and paste on sheet 'Invoice' in C16.
The code just keeps looping (not looping in a code sense, it just seems to keep flickering the screen like its going over & over) until it locks up 5-10 seconds-ish and then I have to re-start Excel.
The range B2:E22 is not always populated, it could possibly be B2:E2 (one row), I dont know how to copy the exact data so I expanded the range to what I think would capture any eventuality....
View 9 Replies
View Related
Apr 27, 2007
auto incrementing my invoices.
The way I do my invoicing is like this. I have 1 Invoice in a worksheet (eg April 1) When I make my invoice for the next day I right click on the April 1 tab at the bottom. Right click/Move copy/move to end &check the create a copy box. It changes to april1(2)I then right click and change the date to the next invoice date. This might seem goofy, but it works for me. I have my Invoice number at the top of the page in cell e2. Is there a formula to automatically increase the invoice number by 1 every time I copy it?
View 9 Replies
View Related
Aug 6, 2006
I have a template of an invoice (in excel) but I need it to automatically
generate a different invoice number every time I open it. Such as 001 the
1st time, 002 the 2nd time etc.
I have no knowledge of macros & do not want to uses Acess.
View 13 Replies
View Related
Oct 9, 2007
I am trying to add a number to invoices (invoice numbers) on a UserForm that is used to make and/or modify scheduled service records for a cleaning business. We fill out the schedule well in advance of when the jobs are scheduled to be done, some customers are on a set schedule such as once a week, everyother week or once a month. Some just call in when they need cleaning. Each day has 27 rows set aside for possible customers (most are not used). We make out as many invoices in advance as is possible and fill-in the rest as they call-in. This leaves a lot of gaps between days
I have an auto-advancing formula tha takes a helper column to give me invouce numbers when there is a customer listed in column B and blanks space where there is no customer listed. This does make for volitile invoice numbers.
Formula in row 3 of the invoice coulmn "A": =IF(B3="","",H3)
Formula in row 3 of helper column "H": =IF(B3="",H2,H2+1)
The helper column only advances if there is a customer listed in column B of that row otherwise it repeates the last number. The invoice column only displays this helper number if there is a customer listed in column B of that row. I can't figure out how to get this to work on a UseerForm with vba.
View 8 Replies
View Related
Jan 22, 2010
Im looking to create an invoice-type format from data in a row but only when the client requests it.
So, if there is a Y in column R. i.e. the client wants an invoice format then.
I have been given a template format by the team manager that I have to use. Its far from ideal, well for me anyway, for moving things around and Im struggling to get anywhere with it.
Im trying to take the data from the row in the source / client worksheet, which will be created via a code from here, and transpose it to a copy of the template worksheet which sits within the same workbook. This is made more complicated because in some cases the data for the invoice will be in two or more rows, because there will be a few items on the same invoice, but they will still be on the same worksheet.
The source / client worksheet has data from columns A to T with a header in row 1.
The details will need to be transposed from the relevant row from each column to the template worksheet as follows
From column in source / client worksheet To cell in copy template worksheet.
From - To
CB2
AB3
BB5
HB7
IB9
GB11
EB13
FB15
RB19
SB21
QB23
OB25
PB27
This is where it gets messy, or more messy should I say
MB33
JB35
LB37
KB39
TB41
NB45
For each of the six sections M to N above there may be more than one relevant items which will be on rows 3 onwards of the source /client worksheet.
So, ideally Im guessing based on if there is data in column A of the source / client worksheet then M to N above will need to copied downwards, i.e. below itself on the template worksheet say from column A and B rows 33-45 copied to A and B rows 47-59 until all the data is copied over.
Blinking eck ... this is a nightmare a real nightmare. This more than one section above is really bad Im at a complete loss.
Although if its really not possible they may have to have another template worksheet with the second, third etc items on as I just cant see this working.
View 9 Replies
View Related
Feb 21, 2014
I'm trying to create a new column which calculates the number of days from the today's date to the due date of an invoice. Also a Column that an invoice is/was overdue.
Column A - Clerk inputs date that invoice was received
Column B - Clerk inputs the date that the bill was paid
Column C - Auto populates the due date of the invoice (20 days after the invoice is received)
Column D - I want a number of days to auto populate based on today's date that will show how many days we have to pay the bill. Example: today is 2/19/2014, bill is due 2/22/2014 (Column C), column D should read 3 (I would prefer is the number is black for "we have days left to pay", red for "we're behind")
*Extra bonus for Column D, if the column goes blank after a date is entered into Column B* - but not necessary
Column E - I would like if the date the bill was paid (Column B) is greater than the date the invoice is due (Column C) to show "Overdue" in the cell.
View 9 Replies
View Related
May 2, 2012
What I'm trying to do is from a template worksheet that I have in a workbook with other worksheets, I'm trying to come up with code that will create a new worksheet based on the template (copy), increment the invoice number, and rename the worksheet tab to be "Invoice # xxxx" (new invoice number from prev. step.).
I have figured out how to use a button on the template to execute, but as I said my VBA skills are lacking to say the least.
View 9 Replies
View Related
Nov 2, 2013
I have multiple rows of data. Some have single invoice number and some have 3. I want to find the rows with multiple same invoice number by filtering then selecting certain data and paste to another sheet.
sheet1 A:I
Name
PO
Chemical
C/T
Center #
[Code]....
View 5 Replies
View Related
May 15, 2014
Our business has a spreadsheet set up for invoicing. A Macro has been created to increase the invoice number, save to the desktop as a PDF with a file name taken from the cells
This is working on my colleagues mac but when we've loaded onto my computer it errors, when I debug I am getting the following error:
Sub Macro3()
'
' Macro3 Macro
'
'
Range("g10").Select
[g10] = [g10] + 1
[Code] .......
View 2 Replies
View Related
Dec 16, 2008
I have this set of number..
987654.
What im trying to do is this..I read this number and check for the first number with the 2nd number. If its greater then i will swap it. Im trying to do this so that my number can be rearranged as 456789.
View 8 Replies
View Related
Jan 22, 2010
I have a userform with two check boxes and four textbox... and i have a command button... i want that when i check checkbox1, the value in textbox1 and textbox2 will appear on cell A1 and A2... and when i check checkbox2, the value in textbox3 and textbox4 will appear in cell A1 and cell A2.
View 9 Replies
View Related
Jun 10, 2014
Obviously there is the Remove Duplicates option but I want something a bit different plus this option won't be available as the workbook is on complete lockdown.
There will always only be 214 rows to check in column B and the data cannot be sorted or it will mess a lot of things up!
Just wondering if there's some code that can check for duplicate entries because for the workbook to work, each row must have a different entry.
When the user selects this sheet a message box pops up telling them they can't have two or more entries the same but I feel this isn't enough as there's nothing actually stopping them doing this.
View 2 Replies
View Related
Apr 12, 2014
I need a vba code to run a macro when a specific word entered in a cell. i.e. when a word "Duplicate" entered in a cell O2, the macro run automatically.
View 1 Replies
View Related
Oct 27, 2009
I have some code that will Kill a DB if it already exists, but I want to check if it exists and warn the user before this happens.
I am not that familiar with ADO, so I was fumbling through the Help topics trying to learn about ADO type names, etc. b/c i thought I could use something like:
If TypeName(MyDB) = "ADODB" Then . . .
but even if that ran, the argument in parentheses would be a string and not the actual DB object, so I am at a loss.
View 9 Replies
View Related
Sep 9, 2006
I want Excel VBA to check for named worksheets. Based on the return, I will have VBA either (1) delete the named worksheets and replace them or (2) refresh the pivot tables on the named worksheet. how to make VBA check for the presence of the named worksheets. My efforts are below and comments at the end of the Sub detail what I want to have happen.
Sub EnterProgram()
Dim Current_P As String, New_P As String
Current_P = Range("data!C2")
If Current_P = "" Then
New_P = InputBox("Which program?")
Do While New_P = ""
Prog = InputBox("Try again... Which program?")
Loop
Range("data!C2") = New_P
ElseIf Current_P = New_P Then
If MsgBox("Use the current program (yes or no)?", vbYesNo) = vbYes Then
Range("data!C2") = New_P
End If........................................
View 2 Replies
View Related
Sep 13, 2006
I have a macro that creates a spreadsheet on a weekly basis and have been using it for quite sometime. Due to the large number of spreadsheets I would like to incorporate some code that would create a folder every month. I would assume that the code would need to include a check routine to see if a folder for that month exsists.
View 3 Replies
View Related
Apr 2, 2007
i want to improve some of my application by testing if a folder is accessible to the user... i've got some code to check if a file is already is use which is useful... but before that we have folders in work that are only accessible to certain users for reporting and if the person doesn't have access to it within a macro it Errors out... i'd like some kind of macro to display a message box like windows does... Directory is not accessible, Access Violation... it has to check directly for the Accessible part and not just an error...
View 2 Replies
View Related