abdelfattah
Well-known Member
- Joined
- May 3, 2019
- Messages
- 1,507
- Office Version
- 2019
- 2010
- Platform
- Windows
hi guy i hope help me the code is somthing wrong i try to transfer data of invoice from sheet1 to sheet 2 but give me this mistake RED LINE
AND GIVE ME RUN TIME ERROR13
Option Explicit
Sub transferData()
Dim i As Long
Dim lastrow As Long
Dim erow As Long
lastrow = Sheets("SHEET1").Range("a" & Rows.Count).End(xlUp).Row
For i = 3 To lastrow
erow = Sheets("SHEET2").Range("a" & Rows.Count).End(xlUp).Offset(1, 0).Row
Range(Cells(i, 1), Cells(i, 6)).copy Destination:=SHEET2.Cells(erow, 1)
Next i
SHEET2.Cells(erow, 6) = WorksheetFunction.Sum(Worksheets(SHEET2).Range("e3:e35"))
End Sub
AND GIVE ME RUN TIME ERROR13
Option Explicit
Sub transferData()
Dim i As Long
Dim lastrow As Long
Dim erow As Long
lastrow = Sheets("SHEET1").Range("a" & Rows.Count).End(xlUp).Row
For i = 3 To lastrow
erow = Sheets("SHEET2").Range("a" & Rows.Count).End(xlUp).Offset(1, 0).Row
Range(Cells(i, 1), Cells(i, 6)).copy Destination:=SHEET2.Cells(erow, 1)
Next i
SHEET2.Cells(erow, 6) = WorksheetFunction.Sum(Worksheets(SHEET2).Range("e3:e35"))
End Sub