Iain A
New Member
Code:
Sub CreateDCT()
'I have an open Excel file (A) where the macro is running from, i then want to open another excel file (B) and copy data from (A) and Paste into (B)
Dim Fname As String
Dim SrcWbk As Workbook
Dim DestWbk As Workbook
Set DestWbk = ThisWorkBook
Fname = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls*), *.xls*", Title:="Select a File")
If Fname = "False" Then Exit Sub
Set SrcWbk = Workbooks.Open(Fname)
'Fails on this line
SrcWbk.Sheets("test sheet with data").Range("A1:D6").Copy DestWbk.Sheets("data from test sheet").Range("A1:D6")
SrcWbk.Close False
End Sub
Last edited: