Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 08-24-2018, 04:55 PM   #16
June7
Newly Registered User
 
June7's Avatar
 
Join Date: Mar 2014
Location: The Great Land
Posts: 2,134
Thanks: 0
Thanked 502 Times in 498 Posts
June7 will become famous soon enough June7 will become famous soon enough
Re: Export query from ms access to excel and create chart

Bing: excel vba get last row number

Read one long discussion on the topic. The first code I tested worked:

i = ws.UsedRange.Row + ws.UsedRange.Rows.Count - 1

__________________
Attach File Manager is below Advanced editor window, click Go Advanced below Quick Reply window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
June7 is online now   Reply With Quote
Old 08-24-2018, 05:17 PM   #17
gippsy
Newly Registered User
 
Join Date: Dec 2012
Posts: 39
Thanks: 12
Thanked 0 Times in 0 Posts
gippsy is on a distinguished road
Re: Export query from ms access to excel and create chart

June7.
I will test the code. As soon as possible, I will let you know if I succeed.

Also, I have been trying this line of code.
Code:
Range("C2", range("D2").End(xlDown)
However, I don't know what I have to write before Range.

Thanks, again.
gippsy is offline   Reply With Quote
Old 08-24-2018, 06:51 PM   #18
June7
Newly Registered User
 
June7's Avatar
 
Join Date: Mar 2014
Location: The Great Land
Posts: 2,134
Thanks: 0
Thanked 502 Times in 498 Posts
June7 will become famous soon enough June7 will become famous soon enough
Re: Export query from ms access to excel and create chart

ws.Range("C2", ws.Range("D2").End(xlDown).Select

Will select the range.

__________________
Attach File Manager is below Advanced editor window, click Go Advanced below Quick Reply window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
June7 is online now   Reply With Quote
Old 09-03-2018, 04:49 PM   #19
gippsy
Newly Registered User
 
Join Date: Dec 2012
Posts: 39
Thanks: 12
Thanked 0 Times in 0 Posts
gippsy is on a distinguished road
Re: Export query from ms access to excel and create chart

June7, Cronk, JHB, Ranman256
For all of you, many thanks.
Finally, I have a code to export and create a chart in excel.
This is my code:
Code:
ub cmdTransfer_Click()
Dim sExcelWB As String
Dim xl As Object ''Excel.Application
Dim wb As Object ''Excel.Workbook
Dim ws As Object ''Excel.Worksheet
Dim ch As Object ''Excel.Chart
Dim myMax As Double
Dim myMin As Double

Set xl = CreateObject("excel.application")
sExcelWB = "D:\testing2\" & qry_01.xls" ''sometimesthe i write "qry_task"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qry_task", sExcelWB, True
Set wb = xl.Workbooks.Open(sExcelWB)
Set ws = wb.Sheets("qry_task")

Set ch = ws.Shapes.AddChart.Chart

gippsy is offline   Reply With Quote
Reply

Tags
charts , qry

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Excel chart from Access VBA (AC2007) AOB Modules & VBA 4 05-13-2014 12:13 AM
Question Access 2007. Export query result to Excel and create SUM per column Petros General 5 11-30-2011 01:33 AM
Can I create this Excel Chart in Access? ions General 1 08-10-2007 04:46 AM
Export data to Excel, Import chart to Access ocular Modules & VBA 0 07-11-2007 04:56 AM
Export Excel Chart to Access Report Automatically ray147 Modules & VBA 2 01-26-2006 08:57 AM




All times are GMT -8. The time now is 02:17 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World