I am trying to automate an excel spreadsheet and then create a chart.
Dim chartRange As Excel.Range
If rollup Then
chartRange = sheet.Range("O2:Q14", Type.Missing)
chartRange.Select()
Else
chartRange = sheet.Range("N:N,M:M,A:A", Type.Missing)
chartRange.Select()
End If
excelBook.Charts.Add()
Dim chart As Excel.Chart = excelBook.ActiveChart
excelApp.ScreenUpdating = False
With chart
.Name = "TPE Graph"
.ChartType = Excel.XlChartType.xlColumnStacked100
.HasTitle = True
.PlotArea.Interior.ColorIndex = 0
.ChartTitle.Text = chartTitle
Dim xlAxisCategory, xlAxisValue As Excel.Axes
xlAxisCategory = chart.Axes(Type.Missing, Excel.XlAxisGroup.xlPrimary)
******* HERE IS ISSUE *****
xlAxisCategory = (.Axes(, Excel.XlAxisGroup.xlPrimary))
xlAxisCategory.Item(Excel.XlAxisType.xlCategory, Excel.XlAxisGroup.xlPrimary).HasTitle = True
xlAxisCategory.Item(Excel.XlAxisType.xlCategory, Excel.XlAxisGroup.xlPrimary).AxisTitle.Font.Bold = True
xlAxisCategory.Item(Excel.XlAxisType.xlCategory, Excel.XlAxisGroup.xlPrimary).AxisTitle.Text = "Week"
xlAxisValue = (.Axes(Type.Missing, Excel.XlAxisGroup.xlPrimary))
xlAxisValue.Item(Excel.XlAxisType.xlValue, Excel.XlAxisGroup.xlPrimary).HasTitle = True
xlAxisValue.Item(Excel.XlAxisType.xlValue, Excel.XlAxisGroup.xlPrimary).AxisTitle.Font.Bold = True
xlAxisValue.Item(Excel.XlAxisType.xlValue, Excel.XlAxisGroup.xlPrimary).AxisTitle.Text = "Actual Efficiency %"
.Legend.Position = Excel.XlLegendPosition.xlLegendPositionBottom
Dim tpeSeries, oppSeries As Excel.Series
tpeSeries = .SeriesCollection(1)
oppSeries = .SeriesCollection(2)
tpeSeries.Interior.ColorIndex = 10
oppSeries.Interior.ColorIndex = 3
If rollup Then
tpeSeries.Name = "TPE"
oppSeries.Name = "Opportunity"
End If
End With
I have checked the web and found many examples but the syntax does not seem to work. I am trying to use Excel.XlCategoryType.xlCategoryScale to get the X variables to scale by category so there are not large gaps between data plots since these are weekly totals. Any suggestions would be great
Thanks,