Macro copying cells from an invoice sheet into a report sheet stopped working properly...

Copper Contributor

after I reformatted some cells in the invoice sheet and added another cell to the report sheet. I am using the following code which was working fine before this change. The new added cell code appears in bold below. It will no longer paste in the next empty row, it repeatedly pastes into row 1 only now.

(of course the rookie foolishly did the changes without backing up the spreadsheet)

 

Sub CreateReport()
Sheets("Invoice").Select
Range("A8").Select
Selection.Copy
Sheets("Report").Select
erow = Sheet3.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Cells(erow, 1).Select
ActiveSheet.Paste

Sheets("Invoice").Select
Range("B8").Select
Selection.Copy
Sheets("Report").Select
erow = Sheet3.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Cells(erow, 2).Offset(-1, 0).Select
ActiveSheet.Paste

Sheets("Invoice").Select
Range("A10").Select
Selection.Copy
Sheets("Report").Select
erow = Sheet3.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Cells(erow, 3).Offset(-1, 0).Select
ActiveSheet.Paste

Sheets("Invoice").Select
Range("B10").Select
Selection.Copy
Sheets("Report").Select
erow = Sheet3.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Cells(erow, 4).Offset(-1, 0).Select
ActiveSheet.Paste

Sheets("Invoice").Select
Range("B12").Select
Selection.Copy
Sheets("Report").Select
erow = Sheet3.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Cells(erow, 5).Offset(-1, 0).Select
ActiveSheet.Paste

Sheets("Invoice").Select
Range("C12").Select
Selection.Copy
Sheets("Report").Select
erow = Sheet3.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Cells(erow, 6).Offset(-1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues

Sheets("Invoice").Select
Range("F26").Select
Selection.Copy
Sheets("Report").Select
erow = Sheet3.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Cells(erow, 7).Offset(-1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues

Sheets("Invoice").Select
Range("E43").Select
Selection.Copy
Sheets("Report").Select
erow = Sheet3.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Cells(erow, 8).Offset(-1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues

Sheets("Invoice").Select
Range("F44").Select
Selection.Copy
Sheets("Report").Select
erow = Sheet3.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Cells(erow, 9).Offset(-1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues

Sheets("Invoice").Select
Range("F45").Select
Selection.Copy
Sheets("Report").Select
erow = Sheet3.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
Cells(erow, 10).Offset(-1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues
End Sub

 

 

0 Replies