Hi everyone!
I found in this forum (VBA - Copy and Paste Range From Multiple Sheets into Summary) the following code (changed somehow in order to transfer various ranges of cells from specific sheets in a new sheet called "summary"). Works great but when I run again the code to add data below previous copied range, selecting different sheets this time, it ovewrittes the first row and then continues nicely all other rows after the previous last row. Can anyone help to find out what goes wrong?
And another one question. Is it possible to mention the namesheet from where each result comes from? Thank you very much for your kind help.
I found in this forum (VBA - Copy and Paste Range From Multiple Sheets into Summary) the following code (changed somehow in order to transfer various ranges of cells from specific sheets in a new sheet called "summary"). Works great but when I run again the code to add data below previous copied range, selecting different sheets this time, it ovewrittes the first row and then continues nicely all other rows after the previous last row. Can anyone help to find out what goes wrong?
And another one question. Is it possible to mention the namesheet from where each result comes from? Thank you very much for your kind help.
VBA Code:
Sub Copy_Range_From_Sheets_De()
On Error GoTo M
Application.ScreenUpdating = False
Dim i As Long
Dim ans As String
Dim Lastrow As Long
Dim Lastrowa As Long
Lastrow = Sheets("de.").Cells(Rows.Count, "A").End(xlUp).Row
Lastrowa = 3
For i = 2 To Lastrow
ans = Sheets("de.").Cells(i, 1).Value
With Sheets(ans)
.Range("e93:o93").Copy
Sheets("Summary").Cells(Lastrowa, 1).PasteSpecial xlPasteValues
Lastrowa = Sheets("Summary").Cells(Rows.Count, "A").End(xlUp).Row + 1
End With
With Sheets(ans)
.Range("e141:o141").Copy
Sheets("Summary").Cells(Lastrowa, 1).PasteSpecial xlPasteValues
Lastrowa = Sheets("Summary").Cells(Rows.Count, "A").End(xlUp).Row + 1
End With
Next
Application.ScreenUpdating = True
Exit Sub
M:
MsgBox "You tried to use a sheet name that does not exist" & vbNewLine & "Or we had another problem"
Application.ScreenUpdating = True
End Sub