1843230 BPCNW UJBR Failed to download file to target destination 1518446 Aggregation of amounts for AST and LEQ accounts at quarter and year level BPC. Sourcedata SourceWorkbook. Sheets1. Cells3, 1. TargetWorkbook. Sheets1. Cells2, 1 Sourcedata. Close Target Workbook. SourceWorkbook. Save. TargetWorkbook. Save. TargetWorkbook. Close False. Process Completed. Msg. Box Task Completed. End Sub. 12. 34. 56. Sub. VBAReadExternalWorkbook Define Object for Target Workbook Dim. TargetWorkbook As. Workbook Dim. SourceWorkbook As. Workbook Dim. TargetPath As. String Assign the Workbook File Name along with its Path Change path of the Target File name TargetPathD Sample. Set. TargetWorkbookWorkbooks. OpenTargetPath Set. SourceWorkbookThis. Workbook With TargetWorkbook object now, it is possible to pull any data from it Read Data from Target File TargetDataTargetWorkbook. Sheets1. Cells1,1 SourceWorkbook. Sheets1. Cells1,1TargetData Update Target File SourcedataSourceWorkbook. Sheets1. Cells3,1 TargetWorkbook. Sheets1. Cells2,1Sourcedata Close Target Workbook SourceWorkbook. Save TargetWorkbook. Save TargetWorkbook. Close False Process Completed Msg. BoxTask CompletedEnd. Sub. 2. VBA Read Excel file or Write To Open WorkbookIf a workbook is already in opened and executing, then you can reference that Excel with its name through Workbooks collection. You have to use the workbook name itself inside the code to read or write content as mentioned in this sample code. Sub WriteToOpenExcel. Dim wb As Workbook. Reference Workbook with its name. WorkbooksBook. 2. WorksheetsSheet. Activate. WorkbooksBook. WorksheetsSheet. Activate. Search for Each Opened Workbook. For Each wb In Workbooks. If wb. Name Book. Then. wb. Sheets1. Cells1, 1 Writing To Open Excel Worksheet Testing. End Sub. Sub. WriteToOpenExcel Dimwb As. Workbook Reference Workbook with its name WorkbooksBook. WorksheetsSheet. Activate WorkbooksBook. WorksheetsSheet. Activate Search for Each Opened Workbook For. Eachwb In. Workbooks Ifwb. NameBook. 2Then wb. Sheets1. Cells1,1Writing To Open Excel Worksheet Testing End. If Next. End. Sub. External Reference to Import Data from another Workbook. With this technique, in the Excel we pull data from another cell by using references. For example, in Cell A1 if we need to get date from Cell B1, we enter B1 in cell A1. This is a reference that is made within the scope of current workbook. In our example if we need to refer the Target sheet, use the command as below. D sample. Sheet. 1 A2. This will fetch the data from the external workbook. Reference from Microsoft How to create External reference and pull data from another excel Data Import Option or ODBCThis is similar to Data Import facility available in Excel. To do this, the Target workbook should be having some table defined in it. To import the data from Target, Go to Source Workbook, Data From Other Sources From Microsoft Query and Give the path of the Target Workbook or use the below code by modifying the File path and Column Header Details. Sub DataImportRecordedMacro. Change File path and Column Headers to Use this code. With Active. Sheet. List. Objects. AddSource. Type 0, Source. ODBC DSNExcel Files DBQD Sample. Default. DirD Driver. Id1. 04. 6 Max. Buffer. Size2. 04. Page. Timeout5. Destination RangeA1. Query. Table. Command. Text Array. SELECT Sheet. Column. 1, Sheet. Column. 2, Sheet. Column. 3 Chr1. Chr1. FROM D Sample. Sheet. Sheet. Row. Numbers False. Fill. Adjacent. Formulas False. Preserve. Formatting True. Refresh. On. File. Open False. Background. Query True. Refresh. Style xl. Insert. Delete. Cells. Save. Password False. Save. Data True. Adjust. Column. Width True. Refresh. Period 0. Preserve. Column. Info True. List. Object. Display. Name TableQueryfromExcelFiles. Refresh Background. Query False. End Sub. Sub. DataImportRecordedMacro Change File path and Column Headers to Use this code With. Active. Sheet. List. Objects. AddSource. Type 0,Source ODBC DSNExcel Files DBQD Sample. Default. DirD Driver. Id1. 04. 6 Max. Buffer. Size2. 04. Page. Timeout5 ,Destination RangeA1. Query. Table . Command. TextArray SELECT Sheet. Column. 1, Sheet. Column. 2, Sheet. Column. 3 Chr1. Chr1. FROM D Sample. Sheet. Sheet. Row. NumbersFalse . Fill. Adjacent. FormulasFalse . Preserve. FormattingTrue . Refresh. On. File. OpenFalse . Background. QueryTrue . Refresh. Stylexl. Insert. Delete. Cells . Save. PasswordFalse . Save. DataTrue . Adjust. Column. WidthTrue . Refresh. Period0 . Preserve. Column. InfoTrue . List. Object. Display. NameTableQueryfromExcelFiles . Refresh Background. Query False End. With. End. Sub. These are some of the methods that are available to import from an external workbook to current active workbook. But still, this is not the limit. There might be other feasible methods known to others. If there is any, please post a reference as you find. Matched Content. You may also like these Posts. Excel VBA Microsoft Excel VBAThis archive is from the original message board at www. Mr. Excel. com. All contents 1. Mr. Excel. com. Visit our online store to buy searchable CDs with thousands of VBA and Excel answers. Microsoft Excel is a registered trademark of the Microsoft Corporation. Mr. Excel is a registered trademark of Tickling Keys, Inc.