Hi
I am looking at the possiblity of copying data from 1 workbook to another without activating the 2nd workbook;.i.e the one I want to copy to
My code at the moment is
$-------------
Sub CopyData()
NbOfTimeStep = 3
NbOfNodes = 3
GroupName="Data" 'This is a variable in reality
Set ActiveReportFile = Workbooks("Book2").Sheets(1)
Set TemplateSheet = Workbooks("template_v1.xls")_
.Worksheets("Template")
TemplateSheet.Copy Before:=TemplateSheet
'Rename sheet just copied
Workbooks("template_v1.xls") _
.Sheets("Template (2)").Name = GroupName
Row = 3
Column = 2
'Error is here
ActiveReportFile.Range(Cells(3,2),Cells(Row + NbOfNodes, Column + NbOfTimeStep)).Copy _
Destination:=Workbooks("template_v1.xls") _
.Worksheets(GroupName) _
.Range(Cells(18, 4), Cells(18 + NbOfNodes, 4 + NbOfTimeStep))
End Sub
$-----------
The programm stops when it tries to copy the data to the destination with "application-defined or object-defined error"
Any suggestions?
Thanks
Regards
JB
I am looking at the possiblity of copying data from 1 workbook to another without activating the 2nd workbook;.i.e the one I want to copy to
My code at the moment is
$-------------
Sub CopyData()
NbOfTimeStep = 3
NbOfNodes = 3
GroupName="Data" 'This is a variable in reality
Set ActiveReportFile = Workbooks("Book2").Sheets(1)
Set TemplateSheet = Workbooks("template_v1.xls")_
.Worksheets("Template")
TemplateSheet.Copy Before:=TemplateSheet
'Rename sheet just copied
Workbooks("template_v1.xls") _
.Sheets("Template (2)").Name = GroupName
Row = 3
Column = 2
'Error is here
ActiveReportFile.Range(Cells(3,2),Cells(Row + NbOfNodes, Column + NbOfTimeStep)).Copy _
Destination:=Workbooks("template_v1.xls") _
.Worksheets(GroupName) _
.Range(Cells(18, 4), Cells(18 + NbOfNodes, 4 + NbOfTimeStep))
End Sub
$-----------
The programm stops when it tries to copy the data to the destination with "application-defined or object-defined error"
Any suggestions?
Thanks
Regards
JB