When we want to carry out work that merits the use of invoices, tables and graphs, we resort to the graphical tool devised by Microsoft and which is none other than the Office Excel application.
But unfortunately, many users who use it are largely unaware of its different functions. In the next tutorial, we are going to show you one of them and it will allow you to create an automatic consecutive numbering using VBA code in Excel.
As we have already mentioned and surely you should also know, this powerful tool is widely used to make the invoice design.
In this article, we will focus on a section that perhaps you did not know or did not believe was possible with this application. This is why we will show you how to create an automatic consecutive numbering.
Perhaps you have done this manual work for a long time and have kept track of each of the invoices you have been issuing. Not knowing that there is a very easy and fast way to make this account automatically. And through the Visual Basic Editor, then we are going to tell you what you must do to put this function into practice.
How to create automatic consecutive numbering using VBA code in Excel
In another article, we touched on the point about using the VBA Macro to search for words in a range or range of cells and highlight them. But now we will concentrate on how to create automatic consecutive numbering using VBA code in Excel.
What we want to achieve, what we want is that each time a new invoice is made, the numbering of each one of them is automatically increased. For example, if today we make an invoice that has invoice number 01, in the next invoice it should appear automatically in the line of Invoice number 02.
If we are clear about what we are looking for with the use of these Exel functions, we can start and the first thing we are going to do is incorporate a code to the Visual Basic Macro. To do this we are going to go to the Macro that we have already created. This can be called New Invoice, New Invoice or simply Invoice.
Entering the code in the VBA Macro
So we want each time we make a clip in the New Invoice Macro, a new one is created, but in the invoice number section that is in cell G7 it is increased. For this we go to the Macro, select and make the right clip, this action will display several options, of which we are going to select Assign Macro.
And now we select the Modify Excel Macro option, here we will find the beginning of the Macro, the name, the different codes that the Macro is going to execute and the end of it. With the cursor, we are going to stop at the last code before the end of the Macro. And then we are going to press the Enter key and copy the following code Range (“G7”). Value = Range (“G7”). Value + 1
You must bear in mind that in the code the variable G7 corresponds to the cell where you want the invoice number to change consecutively. You must place the corresponding cell on your invoice, now we just have to close all the new windows that we open. And in this simple way is that an automatic consecutive numbering is created using VBA code in Excel.
Now, you just have to check if the code that has been incorporated into the Macro works optimally. So to do this, we must make a clip on the New Invoice Macro and this action will generate a new invoice and we will realize that the numbering is increased automatically.
We hope that this tutorial has been to your liking and allows you to work with your invoices in a faster and more orderly way, leaving the calculations for the application. In this way, we finished a new article that in a very simple way shows you how to create an automatic consecutive numbering using VBA code in Excel.