I am trying to copy a range of cells that change in a loop. The range then is pasted in another workbook. I would like to not have to Activate the sheet and the workbook each time. My code now looks like this
For i = 1 to 5
Dim Frontiere As Workbook
Set Frontiere = Workbooks("Frontiere.xlsx")
Dim Summary as Workbook
Set Summary = Workbooks("Summary.xlsx")
Dim Variables As Worksheet
Set Variables = Frontiere.Worksheets("Variables")
Dim Scenarios as Worksheet
Set Scenarios = Summary.Worksheets("Scenarios")
' Copy new variable
Scenarios.Range(Cells(7, i), Cells(57, i + 1)).Copy
Variables.Cells(6, 12).PasteSpecial Paste:=xlPasteValues
Next i
When I try this, I get the Error message "Method 'Range' of object'_Worksheet' failed, coming fron the line "Scenarios.Range(Cells(7, i), Cells(57, i + 1)).Copy"
I would really like not having to Activate the worksheet each time since I have around 20 other ranges to copy and paste for each loop.
Thanks