excel_beginer
New Member
- Joined
- Dec 28, 2017
- Messages
- 19
Hi all
I have file want to copy data from 3 sheets to one, data need copy from range (B2:I) to lastrow of each sheet
Finally sumtotal from lastrow from 3 sheet in lastrow of this sheets
I coding like belove but not work, please help me
I have file want to copy data from 3 sheets to one, data need copy from range (B2:I) to lastrow of each sheet
Finally sumtotal from lastrow from 3 sheet in lastrow of this sheets
I coding like belove but not work, please help me
Code:
Sub PL3PL7()Dim lastRow1 As Long, lastRowPL3BC As Long, lastRowPL7BC As Long, lastRowPL7BCTCVM As Long, cel As Range
lastrowPL3BC = Sheets("PL3BC").Cells(Rows.Count, 3).End(xlUp).Row
lastrowPL7BC = Sheets("PL7BC").Cells(Rows.Count, 3).End(xlUp).Row
lastrowPL7BCTCVM = Sheets("PL7BCTCVM").Cells(Rows.Count, 3).End(xlUp).Row
lastrow1 = Sheets("phantich").Cells(Rows.Count, 3).End(xlUp).Row
With Sheets("phantich")
.Range("A5:I" & lastrow1).ClearContents
Sheets("PL3BC").Range("B2:I" & lastrowPL3BC).Copy
.Range("B6").PasteSpecial xlPasteValues
Sheets("PL7BC").Range("B2:I" & lastrowPL7BC).Copy Destination:=.Cells(lastrow1 + 1, "B")
Sheets("PL7BCTCVM").Range("B2:I" & lastrowPL7BCTCVM).Copy Destination:=.Cells(lastrow1 + 1, "B")
.Range("D1").Offset(lastRow1).Value = Sheets("PL3BC").Range("D" & lastrowPL3BC).Value + Sheets("PL7BC").Range("D" & lastrowPL7BC).Value + Sheets("PL7BC").Range("D" & lastrowPL7BCTCVM).Value
End With
End Sub