First of all I would to thanks to community of Stack Overflow. The many posts here helped to build an billing data file in Google spreadsheet with Scripts to convert invoices to pdf, send them by email, clear specific cells of the invoice after pdf generation, etc.
However, I am struggling now to export sales data from the Invoice to 2 other sheets (Sales and Products) to be able to make some analysis
Invoice looks like this: Invoice It can contain 1 to 10 lines of different products
Here is the link to my spreadsheet:
https://docs.google.com/spreadsheets/d/11MDwYbCDHJy0rUtnYWEk4k8Ow0KvppNSu13B7uZWU1g/edit?usp=sharing
What I want to do:
- for each non-empty line of sheet "INVOICE", I want to copy specific cells to sheet "SALES" that contains following info:
Invoice #, Date, Name, Surname, Email, Ref, Product name, Quantity, Total price after rebate, Mode of payment
I want 1 line / product sold
Hence, if 2 products references are sold, I will have to copy "Invoice #, Date, Name, Surname, Email and Mode of payment" twice
I tried using several functions (lastrow,etc.) but this is not a basic copy (for me at least) as I am not copying an entire row
To make it simple, I ended up writing a script that copy the 10 lines of the invoice (no matter they are empty or not)
But this gives me 2 problems: my script takes ~20 sec to run and it copies Invoice #, Date, Name,... for lines that have no sales data
Then I have to delete manually these lines. If I create a script to delete these lines, that would be even slowlier
In Sales sheet, I have Vlookup formulas (yellow columns) that I would like to be copied down when I create a new row or add data in a new row Again, I couldn't do that
In sheet "Products", adjust the inventory quantity each time I sell a product For this purpose, I have created a column "Sold qtties" (Column E) that I would like to increment by the qtties sold in the invoice
I would really appreciate if some of you could help me here.