check such proposition:
Sub copypaste2()
Dim FileName As Variant
Dim SourceFile as Workbook, MainFile as workbook : Set MainFile=ThisWorkbook
FileName = Application.GetOpenFilename(filefilter:="Excel files (*.xls*),*.xls*", FilterIndex:=3, Title:="Choose a file")
If FileName = False Then
MsgBox "No file selected!", vbcritical
Exit Sub
else
' here your code:
Range("C10:G11").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Range("$A$9:$I$500").AutoFilter Field:=9, Criteria1:=">0", _
Operator:=xlAnd
Selection.Copy
'changed
Workbooks.Open(Filename)
Range("C61").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
'changed:
msgbox "finished copying from " & Filename
'and either:
sourcefile.close false
'or (remove comment char = ' below and add above)
' Mainfile.activate
Range("G64").Select
'added
end if
End Sub
Bookmarks