Hi,

I got someone to write some code for me a while back that produces invoices on the click of a button.

The macro basically takes data from one Excel spreadsheet and drops it into another Excel spreadsheet which is in the form of an invoice.

Yesterday I made some changes to the part of the macro where data is being placed in the invoice. I am not an experienced programmer but made the changes just by using common sense. To my surprise the changes I made seemed to work perfectly, but, now after the invoices have all been produced, I get an error message saying Excel must close. This is a strange error because it seems to pop up after I have already saved and closed all Excel files. It isn't causing any problems as such but I am just wondering why I am getting this error message now when I didn't before.

My guess is that I have done something wrong with my coding. Bearing in mind the changes are working I don't really need to explain what the code is doing. All I need to know is if it is 'bad coding' that may be creating the problem....

Previous code:
            wsInv.Range("J59").Value = .Cells(Itm.Row, MvPrice).Value 'move price
            wsInv.Range("J60").Value = .Cells(Itm.Row, DiscPr).Value  'disc price
            wsInv.Range("J61").Value = .Cells(Itm.Row, VAT).Value  'VAT
            wsInv.Range("J63").Value = .Cells(Itm.Row, Extras).Value  'extras
            wsInv.Range("J65").Value = .Cells(Itm.Row, TotalPr).Value 'TOTAL
After my changes:

            wsInv.Range("J59").Value = .Cells(Itm.Row, MvPrice).Value 'move price
            wsInv.Range("J60").Value = .Cells(Itm.Row, DiscPr).Value  'disc price
            wsInv.Range("J61").Value = .Cells(Itm.Row, Extras).Value / 5 * 4 'extras
            wsInv.Range("J63").Value = .Cells(Itm.Row, Extras).Value / 5 + .Cells(Itm.Row, VAT).Value 'VAT
            wsInv.Range("J65").Value = .Cells(Itm.Row, TotalPr).Value 'TOTAL

The changes are basically to do with where and how VAT is displayed on the invoice. Are my changes causing the error or is my coding ok?