Eagle44
05-28-2008, 05:43 PM
Hi,
the above run time error occurs when I run the macro for the first time after opening the spreadsheet, normally I just click "End" and run the macro again and it works fine. Thought that I better fix the problem. part of the macro is below:
Application.DisplayAlerts = False
Sheets("Chart1").Select
ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True
Range("AF5:AG25").Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("Data").Range("AF5:AG25"), PlotBy _
:=xlColumns
ActiveChart.SeriesCollection(1).Name = "=""Scanned"""
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="Chart1"
With ActiveChart
.HasAxis(xlCategory, xlPrimary) = True
.HasAxis(xlValue, xlPrimary) = True
End With
ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale
the line that causes the error is
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="Chart1"
but as I said only the first time running after opening
Could someone please tell me what I am doing wrong. Many thanks
the above run time error occurs when I run the macro for the first time after opening the spreadsheet, normally I just click "End" and run the macro again and it works fine. Thought that I better fix the problem. part of the macro is below:
Application.DisplayAlerts = False
Sheets("Chart1").Select
ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True
Range("AF5:AG25").Select
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("Data").Range("AF5:AG25"), PlotBy _
:=xlColumns
ActiveChart.SeriesCollection(1).Name = "=""Scanned"""
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="Chart1"
With ActiveChart
.HasAxis(xlCategory, xlPrimary) = True
.HasAxis(xlValue, xlPrimary) = True
End With
ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale
the line that causes the error is
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="Chart1"
but as I said only the first time running after opening
Could someone please tell me what I am doing wrong. Many thanks