kh40sth30ry
New Member
- Joined
- May 8, 2011
- Messages
- 9
Hello,
I'm new to excel vba, currently using Excel 2010. Recently, i need to basically Copy from last row of everysheets from workbook A and paste into sheet1 of workbook B. I tried to write the code for it as followed:
The problem i have is that it keeps pasting into Row 1 of workbook B and doesn't move to the next row. I don't know how to fix my loop. Anyhelp would be really appreciated.
Thank you.
I'm new to excel vba, currently using Excel 2010. Recently, i need to basically Copy from last row of everysheets from workbook A and paste into sheet1 of workbook B. I tried to write the code for it as followed:
Code:
Sub CopyData1()
Workbooks.Open Filename:="C:\ExcelLearning\Simple.xlsx"
InactiveWorkbook = "Simple.xlsx"
CurrentWorkbook = "DataSet1.xlsm"
Dim RowCounter As Integer
For RowCounter = 1 To 3
For i = 1 To 3
Windows(CurrentWorkbook).Activate
Sheets(i).Select
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
Range(Cells(FinalRow, 1), Cells(FinalRow, 10)).Copy
Windows(InactiveWorkbook).Activate
Cells(RowCounter, 1).Select
ActiveSheet.Paste
Windows(CurrentWorkbook).Activate
Next i
Next RowCounter
End Sub
Thank you.