Hello,
I am trying to embed a column chart within a spreadsheet. Currently I can get the chart on the spreadsheet I want. The sourcedata is working correctly. I cant figure out how to add an X axis and currently when I add the chart I am using numbers to add the chart. I would like to be able to use the cell location with variables, instead if this is possible. On the current chart that would mean the top would be row 15, left =column A, right =column N, bottom = row 45. Also I cant seem to be able to remove the series label.
Any help would be appreciated.
Tom
I am trying to embed a column chart within a spreadsheet. Currently I can get the chart on the spreadsheet I want. The sourcedata is working correctly. I cant figure out how to add an X axis and currently when I add the chart I am using numbers to add the chart. I would like to be able to use the cell location with variables, instead if this is possible. On the current chart that would mean the top would be row 15, left =column A, right =column N, bottom = row 45. Also I cant seem to be able to remove the series label.
Any help would be appreciated.
Tom
Code:
Function AddChartSheet(strSheet As String, intRow As Integer, intLastRow As Integer)
Dim cht As ChartObject
Dim rng As Range
'intRow is first row of data
'intLastRow is lastRow of Data
Set cht = ActiveSheet.ChartObjects.Add(Left:=2, Width:=950, Top:=225, Height:=375)
With cht.Chart
.SetSourceData Source:=Sheets(strSheet).Range("N" & intRow & ":" & "N" & intLastRow), PlotBy:=xlColumns
'Remove Series label
.ApplyDataLabels ShowSeriesName:=False
End With
'Assign the XAxis
[Blue] With ActiveChart.SeriesCollection.NewSeries [/Blue]
.XValues = ActiveSheet.Range("A" & intRow & ":" & "A" & intLastRow)
End With
End function