473,758 Members | 4,381 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access VBA to Excel Transfer

4 New Member
I want to output the results from an access query to an existing excel worksheet within a workbook. I do not want to delete the worksheet as another worksheet is tied in with formulas. I have no idea how to do this please help!
Jul 14 '08 #1
1 2118
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi. In a response I made to a previous poster (post #6 of this thread) I provided two VBA routines which together allowed the poster to transfer data from Access to a pre-existing Excel workbook template (or any other Excel workbook). This same code can be used in your case, substituting the name of your file for the template name. You need to make one small addition: when you open the workbook you have to select the sheet into which you want the data copied. This is done by adding a new line at line 21 of the TransferSpreads heet method in post 6 above:
Expand|Select|Wrap|Line Numbers
  1. ...
  2.     end if
  3.     objExcel.Worksheets("name of your worksheet").activate ' << add this line
  4.     TransferQueryData Tablename, objExcel
  5.     ...
if you do not have an existing blank sheet in your workbook into which you want to copy the data you will need to add a new worksheet instead. This is done by changing the worksheet selection line (line 3 above) to one that adds a worksheet:

Expand|Select|Wrap|Line Numbers
  1.      objExcel.ActiveWorkbook.Worksheets.Add Before:=objExcel.Worksheets(1)
Either way, all existing sheet references for other worksheets are not altered in any way by copying the Access data to a blank existing sheet or into a new worksheet.

-Stewart
Jul 15 '08 #2

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

Similar topics

6
18848
by: Paul | last post by:
I was wondering if anyone has had an issue where using vba code to read an excel file and import the data into an access table some records are not imported from the excel file. It seems looking at the data in the excel file that if the first character in the excel file cell is numeric it will read and write only numeric values only. If I sort the coloumn in the excel file and the first character in the cell read is alphanumeric then only...
7
5144
by: Keon | last post by:
Hoi, I'm using a database with alot of records in 1 table (more than 3000). If i want to export this table to excel i only get it till record 2385. Do someone know how i can solve this probleme? To export my tables i use folowing code: StTotaal = stLocatieName & "\Archief\" & Year(Date) & Month(Date) & Day(Date) & "_Gegevens.xls" 'location and name where the table must be saved
1
3347
by: com | last post by:
Extreme Web Reports 2005 - Soft30.com The wizard scans the specified MS Access database and records information such as report names, parameters and subqueries. ... www.soft30.com/download-1-11975.htm - 31k - Cached - Similar pages MDBSecure 1.0.8.0 - Soft30.com Utility which makes it easy to create secure MS Access Databases, ... MS Access 2000/2003 format. 30 day money back guarantee, 30 day trial. ...
15
2435
by: sparks | last post by:
We get more and more data done in excel and then they want it imported into access. The data is just stupid....values of 1 to 5 we get a lot of 0's ok that alright but 1-jan ? we get colums that are formatted for number and then half way down they are changed to text. OR the famous ok now everything in red is ---- and everything in blue is---------. WTF are these people thinking?
4
9933
by: vancehome | last post by:
I have a series of macros running everynight creating tons of excel files (using transfer spreadsheet). I then have another program that zips them up and emails them all over the place. It then deletes the originals. I would like to move away from the emailing and begin pushing the files out directly via the WAN. The problem is I need to DELETE the existing excel files before they are recreated everynight. There seems to be some glitch that...
0
3066
by: blainegray | last post by:
Greetings This is one of those Access is not closing Excel problems. The first time through the code works fine. The second time there is a problem. After lots of combinations, I finally determined that if I take out the line that copies the temp array to cells in a worksheet, Access will close the Excel file. If the line is there, Excel remains open and blocks more runs of the same procedure. If I close Access, Excel gets closed. Looks like...
5
3222
by: billa856 | last post by:
Hi I am totaly new to MS Access. I have one worksheet in excel in which I have data of company's inventory. I want to know can I transfer data from a form made in MS Access to the Excel worksheet? Can I use access form to fetch or update data in excel worksheet? Can I use MS Access as frontend Or I have to use another frontend like VB?
0
6225
by: Tony Hine | last post by:
Problem for Excel Developers One of the problems facing Excel developers moving into MS Access is actually the apparent similarity between MS Access tables and Excel spreadsheets. MS Access is NOT Excel This similarity of the “look” in both programs, the layout of the data, leads to the Excel developer mistakenly thinking that a database works in a similar way to a spreadsheet. Flat File Database Spreadsheets are very sophisticated...
7
13174
by: kpresidente | last post by:
Hello all, I'm trying to transfer the value of a control on an Access form to an Excel worksheet using VBA. The Access form is a single form with all the controls disabled, so that data is "read only." I have a button on the form which opens the Excel worksheet, which then basically serves as the input form for the Access database. What I need is to somehow get the primary key (EstimateID) of the current record on the Access form...
2
2635
by: shalskedar | last post by:
In the excel sheet attached below can the particular data b transfered to Access. The data is more of the dimensions data i.e the tabular data in the sheet has to go to Access...Based on the data various other Reports can b generated... Plz let me know how to transfer this data from various sheets to Access...
0
9492
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10076
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9908
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9740
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8744
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6564
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5332
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3832
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2702
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.