Range of Object _Global Failed

Discussion in 'Microsoft Excel Charting' started by Jeffrey Marks, Jul 13, 2011.

  1. I'm trying to create multiple charts via a macro in Excel 2007.

    I'm getting a 1004 - Range of Object _Global Failed on the indicated statement. I believe I've done something wrong with the last Range in that statement, but I'm not sure what.


    Sub OATChartCreate()

    Dim chtNew As Chart
    Dim i As Integer '<<<
    ActiveCell.Resize(2.6).Select
    ActiveSheet.Shapes.AddChart.Select
    Set chtNew = ActiveChart
    For i = 1 To 109 '<<<
    Range("F1:K1,F2:K2").Select
    Range("F2").Activate
    ActiveCell.Resize(2.6).Select
    ActiveSheet.Shapes.AddChart.Select
    Set chtNew = ActiveChart
    >>> chtNew.SetSourceData Source:=Range( _

    "'OAT Test Charts Data_Crosstab'!$F$1:$K$1, Range(ActiveCell,ActiveCell.Offset(0,6)).Select" _
    ) <<<
    chtNew.ChartType = xlColumnClustered
    chtNew.Legend.Delete
    chtNew.HasAxis(xlValue) = True
    chtNew.Axes(xlValue).MinimumScale = 0
    chtNew.Axes(xlValue).MaximumScale = 1
    chtNew.Axes(xlValue).MajorUnit = 0.1
    chtNew.Axes(xlValue).MajorUnit = 0.2
    chtNew.Axes(xlValue).TickLabels.NumberFormat = "0.00%"
    chtNew.Axes(xlValue).TickLabels.NumberFormat = "0%"
    ActiveChart.ChartArea.Select
    chtNew.SetElement (msoElementPrimaryValueAxisTitleVertical)
    chtNew.SetElement (msoElementChartTitleAboveChart)
    chtNew.ChartTitle.Text = "Adams County - 8th Grade Mathematics Results"
    chtNew.Axes(xlValue, xlPrimary).AxisTitle.Text = "Percent Passing"
    Range("F2").Offset(i, 0).Select
    Next i
    End Sub

    Thanks

    Jeff
     
    Jeffrey Marks, Jul 13, 2011
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Justin Smith

    Setting Source Data to a Named Range rather than cell Range

    Justin Smith, Dec 5, 2003, in forum: Microsoft Excel Charting
    Replies:
    2
    Views:
    344
    Justin Smith
    Dec 5, 2003
  2. spoefi

    Excel VBA method Cells of object _global failed

    spoefi, Mar 16, 2004, in forum: Microsoft Excel Charting
    Replies:
    3
    Views:
    3,771
    c2shar
    Jun 15, 2015
  3. Ajay_N
    Replies:
    1
    Views:
    298
    Jon Peltier
    Aug 15, 2006
  4. Guest

    Macro error, range object need data?

    Guest, Jun 14, 2007, in forum: Microsoft Excel Charting
    Replies:
    1
    Views:
    172
    Andy Pope
    Jun 15, 2007
  5. SysMod

    Method 'Left' of object 'DataLabel' failed

    SysMod, Jul 10, 2009, in forum: Microsoft Excel Charting
    Replies:
    2
    Views:
    991
    SysMod
    Jul 10, 2009
Loading...

Share This Page