473,466 Members | 1,313 Online
Bytes | Software Development & Data Engineering Community
Create 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 2094
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 TransferSpreadsheet 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
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...
7
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...
1
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. ......
15
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...
4
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...
0
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...
5
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?...
0
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...
7
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...
2
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
1
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...

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.