Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying from 1 workbook to another

Status
Not open for further replies.

jobur

Technical User
Aug 30, 2005
6
GB
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
 

JB,

This is a NON-VBA Forum.

Please post in forum707, VBA Visual Basic for Applications (Microsoft)

Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top