473,396 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Combine files into one Excel Sheet using Access VBA

Is there a way i can combine Multiple Excel workbooks into One Excel Workbook using Access VBA. Something like when a user clicks on a button in access it will generate excel files and combine them to one excel workbook with different worksheets in it. TIA
Feb 7 '19 #1
1 1731
Luuk
1,047 Expert 1GB
Yes you can to that in Excel.
first create two EXCEL-sheets, and than combine them using Excel

Expand|Select|Wrap|Line Numbers
  1. Function Macro1()
  2. On Error GoTo Macro1_Err
  3.     DoCmd.OutputTo acOutputTable, "Tabel1", "ExcelWorkbook(*.xlsx)", "d:\temp\tabel1.xlsx", False, "", , acExportQualityPrint
  4.     DoCmd.OutputTo acOutputTable, "Tabel1", "ExcelWorkbook(*.xlsx)", "d:\temp\tabel2.xlsx", False, "", , acExportQualityPrint
  5.  
  6.     Dim MyXL As Object
  7.  
  8.     Set MyXL = CreateObject("Excel.Application")
  9.     With MyXL
  10.         .Workbooks.Open "d:\temp\tabel1.xlsx"
  11.         .Workbooks.Open "d:\temp\tabel2.xlsx"
  12.  
  13.         .Workbooks("tabel2.xlsx").Sheets("Tabel1").Select
  14.         .Workbooks("tabel2.xlsx").Sheets("Tabel1").Name = "Tabel2"
  15.         .Workbooks("tabel2.xlsx").Sheets("Tabel2").Copy After:=.Workbooks("tabel1.xlsx").Sheets(1)
  16.         .Workbooks("tabel2.xlsx").Close SaveChanges = False
  17.         .Application.Visible = True
  18.     End With
  19.  
  20. Macro1_Exit:
  21.     Exit Function
  22.  
  23. Macro1_Err:
  24.     MsgBox Error$
  25.     Resume Macro1_Exit
  26.  
  27. End Function
  28.  
  29.  
  30.  
Of course you should delete "Tabel2.xlsx", but that's up to you ...
Feb 9 '19 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: B.N.Prabhu | last post by:
How to delete first row from an Excel Sheet using C#.Net. Please Help. Its very urgent.
5
by: Rishika14 | last post by:
Hi, Somebody pls tell me how to export data from webpage to excel sheet using java script. rishika
1
by: gowthamkumar | last post by:
HII ... please give me a code to open a new excel sheet using VB so that i can also directly add some contents in the cells of the excel sheet in VB itself .. i ve use the existing excel sheet code...
4
by: sandeep123456 | last post by:
hi, can we send data from html to excel sheet using java script sandeep
2
by: abiramii | last post by:
Hi How to Import datagridview datas to excel sheet using c#.net(win forms)
3
by: dileepkms | last post by:
can we disable copy and paste functionality for excel sheet using javascript? if we do it, can you send me the code
2
by: sanjuindia2005 | last post by:
How can i read the excel sheet using javascript ?
0
by: satenova | last post by:
Hello Friends, I am newbie when it comes to vb.net and i need to import excel sheet into access db using vb.net application. Here is the code i use for now to upload excel sheet and it works...
4
by: =?Utf-8?B?Sm9zaW4gSm9obg==?= | last post by:
I could create MS Excel sheet using ASP.NET 2.0 with C# but it is not being created in some systems, following error occurs when the program compiles : Microsoft Office Excel cannot open or...
1
by: sree ram | last post by:
code for getting maximum rows in excel sheet using perl script
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.