Hi,
I try to copy the date from multiple summary sheets(in differentr wbs) in one new workbook called for the moment Summary_test.xls
The problem I encounter is that the lastRow=ActiveSheet.UsedRange.Rows.Count
doesn't return the actual last line but the lastRow used - 1, any ideas what's wrong ?
here is the code
Thank to all!
P.S. Of course with the lastrow+1 the first copied rows start from row 2 in the new workbook, which was not initially the idea
I try to copy the date from multiple summary sheets(in differentr wbs) in one new workbook called for the moment Summary_test.xls
The problem I encounter is that the lastRow=ActiveSheet.UsedRange.Rows.Count
doesn't return the actual last line but the lastRow used - 1, any ideas what's wrong ?
here is the code
Code:
Sub Summary_In_NewWorkbook()
Dim i As Double
Dim wbname As String
wbname = ActiveWorkbook.Name
Workbooks(wbname).Activate
Sheets("Summary").UsedRange.Copy
Workbooks("Summary_test.xls").Activate
LastRow = ActiveSheet.UsedRange.Rows.Count
' the msgBox was added after I detected the problem!
MsgBox ("last row used is: " & LastRow & "lastrow+1= " & LastRow + 1)
Cells(LastRow + 1, 1).Select
Sheets("Sheet1").Paste
End Sub
P.S. Of course with the lastrow+1 the first copied rows start from row 2 in the new workbook, which was not initially the idea