genracela
07-11-2010, 07:23 PM
I'm trying to copy data from one file to another.
My filename is in C1.
I copied a code and modified it based on my requirements, but unfortunately it returned an error on this line:
Workbooks("str" & ".xls").Sheets("sheet1").Range("A1: 5000").Copy
Option Explicit
Sub CopyTo()
Dim str As String
str = Range("C1").Value
Workbooks("str" & ".xls").Sheets("sheet1").Range("A1:D5000").Copy
ThisWorkbook.Sheets("Data").Range("A3").PasteSpecial Paste:=xlPasteValues
End Sub
Thanks!
My filename is in C1.
I copied a code and modified it based on my requirements, but unfortunately it returned an error on this line:
Workbooks("str" & ".xls").Sheets("sheet1").Range("A1: 5000").Copy
Option Explicit
Sub CopyTo()
Dim str As String
str = Range("C1").Value
Workbooks("str" & ".xls").Sheets("sheet1").Range("A1:D5000").Copy
ThisWorkbook.Sheets("Data").Range("A3").PasteSpecial Paste:=xlPasteValues
End Sub
Thanks!