Hi, I am new to the forum and working with vba code. I admit most of my work to date has been sourced from google searches and self leaning how to write code. I therefore consider myself a complete novice so appreciate any help.
Now, my project is to make a basic invoice sheet with vba code that copies the template layout to a new workbook and saves it as a new file name. Additionally, I have code for incrementing the invoice number by 1 and clearing the cells with the details so the template layout is ready for the next invoice. I also have code that copies some cells to another workbook, named accounts showing some invoice details such as invoice number, name and date.
Now my problem is when my new workbook is created I obviously then have a saved record of the invoice but without any of the code from the originating file which created it. I have managed to write into my code a way of generating a new module in the new workbook but cannot figure out how to add code to this new module from with the original workbook. I hope not to sound too confusing, but what I need is to generate a new workbook, module and code using vba to execute this. The reason I need to add this code to the newly created workbook is so that any edits to the information entered can be updated to the accounts list.
So this leads to my next question. Currently I am able to copy cells to a new workbook (accounts) and enter the information to the next clear row. But, how do I add a check to see if the invoice number is already present in my accounts workbook and if so replace the row instead of adding it to the next clear row. This is the code which I will use in my newly created workbook / module thus allowing me to edit the new workbook and update the accounts workbook.
So, the code I have so far is as follows:-
I appreciate any guidance / changing my code anyone on the forum can help me with,![]()
Please Login or Register to view this content.
Many thanks
Andy
Bookmarks