Transfer data into Invoice

Solved/Closed
semperfi90 Posts 2 Registration date Friday April 11, 2014 Status Member Last seen May 18, 2014 - Apr 11, 2014 at 11:18 AM
 semperfi90 - Apr 28, 2014 at 10:55 AM
So I've put hours and hours into this with no avail. Here's my situation...I have on "Sheet 1" a list of materials which could potentially be used during a job. I have it set up so that if I populate the quantity column (i.e. I used 1 or 2 during the job) it will give a sub-total and grand total at the bottom of the sheet.

I have an invoice template on "Sheet 2". My idea is...if on sheet 1 I populate the quantity column (obviously I used the item and will be charging the customer for it). I want the description (in column 1), the quantity (in column 2), and the price (in column 3) to be copied over to my invoice sheet if AND ONLY IF I populated the quantity column on sheet 1.

Please help!

1 reply

TrowaD Posts 2900 Registration date Sunday September 12, 2010 Status Moderator Last seen September 12, 2022 523
Apr 14, 2014 at 10:59 AM
Hi Semperfi,

It is possible to copy you data to another sheet automatically whenever the quantity is entered.
But what will its locations be?

Or you do want to enter all the quantities first and then run the code manually to create the invoice?

Do you want to remove the quantities after running the code?

Let me know.

Best regards,
Trowa
0
I have my listing as quantity, description, price (columns A, B, C) on sheet 1. My invoice on sheet 2 matches that in order and column.

I want it to be like this...I enter 1 in the quantity column on sheet 1. The software copies the quantity, description and price and puts it on my invoice. So when I'm done if I used 5 different items from sheet 1 (out of probably 100), the 5 items I entered a quantity for will be populated (accordingly) on my invoice.
0
TrowaD Posts 2900 Registration date Sunday September 12, 2010 Status Moderator Last seen September 12, 2022 523
Apr 15, 2014 at 10:38 AM
Hi Semperfi,

To make this work I assumed that column A on the invoice sheet (Sheet2) is empty, except for any headers you might have.

You didn't specify if you wanted the quantities to reset, so check the green text in the code.

Implement the following code by right-clicking sheet1's tab, selecting View code and pasting the code in the big white field of the newly opened window:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Columns("A:A")) Is Nothing Then Exit Sub
If Target.Cells.Count > 1 Then Exit Sub
If Target = vbNullString Then Exit Sub
If IsNumeric(Target) = False Then Exit Sub

Range(Cells(Target.Row, "A"), Cells(Target.Row, "C")).Copy
Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial

'If you want the quantity to reset, then remove the apostrophe at the beginning of the below sentence
'Target.ClearContents

Application.CutCopyMode = False

End Sub


Best regards,
Trowa
0
Thanks lot TrowaD this got me on the right track. The only thing I haven't remedied is this. The code you supplied me gives me everything I need on Sheet 2, but it puts it at the bottom of my invoice. My informal table I'd like it copied into is from A18:C34. Is there a way I can make it go to that location and populate down? I modified your code to the following:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Columns("A:A")) Is Nothing Then Exit Sub
If Target.Cells.Count > 1 Then Exit Sub
If Target = vbNullString Then Exit Sub
If IsNumeric(Target) = False Then Exit Sub

Range(Cells(Target.Row, "A"), Cells(Target.Row, "C")).Copy
Sheets("Sheet2").Range("A18").PasteSpecial

Application.CutCopyMode = False

End Sub


When I do that I get my data starting in A18 like I want, but when I use another "piece of equipment" from Sheet 1, it pastes over top of A18. Can I alter this just a tad to have them go down the column?
0
TrowaD Posts 2900 Registration date Sunday September 12, 2010 Status Moderator Last seen September 12, 2022 523
Apr 22, 2014 at 10:19 AM
Hi Semperfi,

That depends on where your other data is located.

If A1:A17 is filled with data you can use:
Sheets("Sheet2").Range("A1").End(xldown).offset(1,0).PasteSpecial
If A17 is filled with data then you can use:
If Sheets("Sheet2").Range("A18") = vbNullString Then
Sheets("Sheet2").Range("A18").PasteSpecial
Else: Sheets("Sheet2").Range("A17").End(xlDown).Offset(1, 0).PasteSpecial
End If

Also note that you can use End multiple times.
So if you have data in A17 and A35 then the following will also work:
Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).End(xlUp).Offset(1, 0).PasteSpecial

If none of these work then let me now which cells in column A contains data.

Best regards,
Trowa
0
Is there a way I can either upload my excel sheet to this forum or send you my excel sheet? The only reason I ask is you seem to understand what you're doing very thoroughly, but I'm not able to explain exactly what I have already established in my excel sheet.
0