473,473 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Exporting from Access to Excel with Groups

1 New Member
Have an end user who prefers to see everything in Excel, neatly grouped.

I know how to export to Excel - but is there a way to export a query from Access directly into Excel with groupings without having to manually establish groups inside the excel spreadsheet? (ie selecting rows of data groupings and hitting shift-alt-right or selecting the 'group' button)

Example:

Query data looks like

Group1 Info Info Info
Group1 Info Info Info
Group2 Info Info Info

What I would like in Excel is for the first two rows to automatically be 'grouped' with the + box to the left of the rows.

Ideas? Its not a major pain to manually format, I am just opposed to it in principle.

Ha.

Thanks in advance.
Dec 21 '07 #1
1 3249
brightshadow
10 New Member
You can manipulate anything in Excel with VBA through Access that you can within Excel itself, if you declare an Excel application object...

Once you've done that, you can just programmatically select the rows you want and use .Selection.Rows.Group in VBA to group the rows.

Here's a snippet of something I recently tacked together for generating Excel documents based on a template (it was easier for me to use a template file than to generate a new Excel workbook for this particular project) -- I know it looks like it could be optimized using a "With," but when I tried doing it that way, it behaved unpredictably for some reason so I was explicit in all my references:

Expand|Select|Wrap|Line Numbers
  1. Dim strXlsPath As String
  2. strXlsPath = Application.CurrentProject.Path & "\Template.xls"
  3.  
  4. Set objExcel = CreateObject("Excel.Application")
  5. Dim mySheet As Worksheet
  6.  
  7. objExcel.Visible = True
  8. objExcel.Workbooks.Open(strXlsPath)
  9. objExcel.Workbooks("Template.xls").Activate
  10. objExcel.Workbooks("Template.xls").Worksheets("Example").Activate
  11. objExcel.Workbooks("Template.xls").Worksheets("Example").Select
  12.  
Et cetera; you can refer to the Excel workbook/worksheets that way and do anything you could do from VBA within Excel at that point. The VBA editor should automatically add the reference you need for the version of Office you're using.

HTH

Have an end user who prefers to see everything in Excel, neatly grouped.

I know how to export to Excel - but is there a way to export a query from Access directly into Excel with groupings without having to manually establish groups inside the excel spreadsheet? (ie selecting rows of data groupings and hitting shift-alt-right or selecting the 'group' button)

Example:

Query data looks like

Group1 Info Info Info
Group1 Info Info Info
Group2 Info Info Info

What I would like in Excel is for the first two rows to automatically be 'grouped' with the + box to the left of the rows.

Ideas? Its not a major pain to manually format, I am just opposed to it in principle.

Ha.

Thanks in advance.
Dec 21 '07 #2

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

Similar topics

3
by: sridevi | last post by:
Hello How to export data from ms-access database to excel worksheet using ASP. mainly i need to export data to multiple worksheets. it is very urgent to us. i have a sample code which works...
5
by: jsudo | last post by:
I have a Access database with a large amount of records (close to 500,000) that I would like to export to Excel. I found out that Excel has the capability of of about 65,000 rows so I know I...
4
by: D | last post by:
I've created a report with many subreports of aggregate data. I want my client to be able to export this data to Excel to make her charts, etc. Only one problem: one of the fields is a "SchoolYear"...
2
by: G | last post by:
When I export data from access to excel by with "export" or "Analyze with" I seem to loose parts of some fields (long text strings). Is there a way to export it all to excel? Thanks G
2
by: Kenneth | last post by:
How do I remove the limitation in Access that deny me from exporting 24000 rows and 17 columns (in a query) into Excel? Kenneth
2
by: Mustufa Baig | last post by:
Hi everybody, I have an ASP.NET website where clients can view their monthly billings by selecting different options. One of the option is the way they want to see the report i.e. whether they...
1
by: Mustufa Baig | last post by:
I have an ASP.NET website where I am showing off crystal reports to users by exporting them to pdf format. Following is the code: ---------------- 1 Private Sub ExportReport() 2 Dim oStream...
6
by: Kevin Humphreys | last post by:
Hi There, I am trying to export a recordset to an excel file using the Content Type below in the header. Response.ContentType = "application/vnd.ms-excel" Which works fine however the...
3
by: jennwilson | last post by:
Access 2000 - I have developed a database that houses patient information. The patient information must be sent in an excel file to another company department. I know how to export my data to Excel...
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
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...
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...
1
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
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...

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.