Hello
I have an Access Db to export a query and create a chart based in worksheet ranges (B2 to last value down) and (C2 to last value down).
My command button my code creates a chart with primary and secondary axes values.
This is my code working well:
My problem here is, I do not know how to tell VBA to read min & max values per range to set each axis values.
I have been googling for hours and hours with no success.
Please. Does anyone know of a workaround to this?
Thanks in advance
I have an Access Db to export a query and create a chart based in worksheet ranges (B2 to last value down) and (C2 to last value down).
My command button my code creates a chart with primary and secondary axes values.
This is my code working well:
Code:
Sub 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 myRange As Object
Set xl = CreateObject("excel.application")
'sExcelWB = "D:\testing2\"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qry_task", sExcelWB, True
Set wb = xl.Workbooks.Open(sExcelWB)
Set ws = wb.Sheets("qry_task")
'Set ch = xl.Charts.Add
Set ch = ws.Shapes.AddChart.Chart
With ch
.ChartType = xlColumnClustered
.SeriesCollection(2).AxisGroup = 2
.SeriesCollection(2).ChartType = xlLineMarkers
.ChartGroups(1).GapWidth = 69
'Chart Title
.HasTitle = True
.ChartTitle.Text = "Plot"
.Axes(xlValue).MajorGridlines.Delete
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
.SetElement (msoElementLegendBottom)
End with
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveSheet.Shapes("Chart 1").IncrementLeft -207
ActiveSheet.Shapes("Chart 1").IncrementTop -237.75
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveSheet.Shapes("Chart 1").ScaleWidth 1.4708333333, msoFalse, _
msoScaleFromTopLeft
ActiveSheet.Shapes("Chart 1").ScaleHeight 1.48090296, msoFalse, _
msoScaleFromTopLeft
xl.Visible = True
xl.UserControl = True
End Sub
My problem here is, I do not know how to tell VBA to read min & max values per range to set each axis values.
I have been googling for hours and hours with no success.
Please. Does anyone know of a workaround to this?
Thanks in advance