Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to embed a chart within a spreadsheet runtime error 91 2

Status
Not open for further replies.

vba317

Programmer
Mar 5, 2009
708
US
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


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

 
I apologize,I will repost in another forum.

Tom
 

faq707-4811


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top