Sub OpenCopyAndClose()
Dim excelFile As String
excelFile = "myfile.xls"
'open excel file "myfile.xls" in drive D:\
Workbooks.Open "D:\" & excelFile
'copy value of range A1 from "myfile.xls"
ThisWorkbook.Sheets(1).Range("D1").Value = _
Workbooks(excelFile).Sheets(1).Range("A1").Value
'close "myfile.xls" file and don't save any changes
Workbooks(excelFile).Close SaveChanges:=False
End Sub
Thank you for reading this article Excel VBA Macro Example: Opening & Closing a Workbook (Excel File) With URL https://x-tutorials.blogspot.com/2009/02/excel-vba-macro-example-opening-closing.html. Also a time to read the other articles.
0 comments:
Write your comment for this article Excel VBA Macro Example: Opening & Closing a Workbook (Excel File) above!