I am having a problem charting 2 columns of data on one single x-axis. I have used the macro recorder to create the macro but it always stops at the same spot. Here is the error code I get "Run-time error "1004":Method "Axes" of object '_Chart' failed. Here is the code from the macro recorder
the part in red is where the code finds an error. It's was just a simple graph with 2 data columns graphed over a date axis. Any help would be appreciated. A second question, how can I code my source data to only use the cells that have a number in them, for this example the Range is ("A1:A22,E1:F22"), but (A, E & F) 22 may not be the last cell with data in itCode:Charts.add ActiveChart.ApplyCustomType ChartType:=xlBuiltIn, TypeName:= _ "Lines on 2 Axes" ActiveChart.SetSourceData Source:=Sheets("Data").Range("A1:A22,E1:F22"), _ PlotBy:=xlColumns ActiveChart.Location Where:=xlLocationAsObject, Name:="Charts" With ActiveChart .HasTitle = True .ChartTitle.Characters.Text = "Est Daily MwH vs $ per MwH" .Axes(xlCategory, xlPrimary).HasTitle = True .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Date" .Axes(xlValue, xlPrimary).HasTitle = True .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Total MwH" .Axes(xlCategory, xlSecondary).HasTitle = False .Axes(xlValue, xlSecondary).HasTitle = False End With With ActiveChart .HasAxis(xlCategory, xlPrimary) = True .HasAxis(xlCategory, xlSecondary) = False .HasAxis(xlValue, xlPrimary) = True .HasAxis(xlValue, xlSecondary) = True End With
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks