ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Charts and Charting in Excel (https://www.excelbanter.com/charts-charting-excel/)
-   -   Jon Peltier's code: can't delete initial series?? (https://www.excelbanter.com/charts-charting-excel/112727-jon-peltiers-code-cant-delete-initial-series.html)

Ed

Jon Peltier's code: can't delete initial series??
 
I wrote this on my machine running Win XP and XL2002. It worked. I gave it
to a friend running Win2000 and XL2000, and it fails on the code to delete
the initial series. What else can we do?

Ed

Sub MakeNewScatterChart()

Dim wkb As Workbook
Dim wks As Worksheet
Dim LastRow As Long
Dim LastCol As Long
Dim colData As Long
Dim cht As Chart
Dim chtObj As ChartObject
Dim rngData As Range
Dim rngXval As Range
Dim rngSer As Range
Dim strTitle As String

' Get limits of data
Set wkb = ActiveWorkbook
Set wks = wkb.Sheets(1)
LastRow = wks.Range("A65536").End(xlUp).Row
LastCol = wks.Range("IV4").End(xlToLeft).Column

' Set data range
Set rngData = wks.Range(Cells(4, 1), Cells(LastRow, LastCol))

' Define X data range
Set rngXval = rngData.Columns(1)

For colData = 2 To LastCol
' Add new chart object
Set cht = wkb.Charts.Add
With cht
.ChartType = xlXYScatterSmoothNoMarkers

''' *** ERROR HERE ***
' Delete initial data series
Do While .SeriesCollection.Count 0
.SeriesCollection(1).Delete
Loop



Jon Peltier

Jon Peltier's code: can't delete initial series??
 
Hi Ed -

I just tested this in Excel 2000 (I think I first started using the
technique in Excel 97) and it ran just fine.

If you want, send me the workbook this fails on, and let me know what range
is selected when the macro starts. I'll see if I can find the problem.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Ed" wrote in message
...
I wrote this on my machine running Win XP and XL2002. It worked. I gave
it to a friend running Win2000 and XL2000, and it fails on the code to
delete the initial series. What else can we do?

Ed

Sub MakeNewScatterChart()

Dim wkb As Workbook
Dim wks As Worksheet
Dim LastRow As Long
Dim LastCol As Long
Dim colData As Long
Dim cht As Chart
Dim chtObj As ChartObject
Dim rngData As Range
Dim rngXval As Range
Dim rngSer As Range
Dim strTitle As String

' Get limits of data
Set wkb = ActiveWorkbook
Set wks = wkb.Sheets(1)
LastRow = wks.Range("A65536").End(xlUp).Row
LastCol = wks.Range("IV4").End(xlToLeft).Column

' Set data range
Set rngData = wks.Range(Cells(4, 1), Cells(LastRow, LastCol))

' Define X data range
Set rngXval = rngData.Columns(1)

For colData = 2 To LastCol
' Add new chart object
Set cht = wkb.Charts.Add
With cht
.ChartType = xlXYScatterSmoothNoMarkers

''' *** ERROR HERE ***
' Delete initial data series
Do While .SeriesCollection.Count 0
.SeriesCollection(1).Delete
Loop





Jon Peltier

Jon Peltier's code: can't delete initial series??
 
Ed -

I don't know if it matters, but I noticed that I usually use a slightly
different syntax.

Do Until .SeriesCollection.Count = 0
.SeriesCollection(1).Delete
Loop

I had tested them both in 2000 prior to my earlier reply, and both worked.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Jon Peltier" wrote in message
...
Hi Ed -

I just tested this in Excel 2000 (I think I first started using the
technique in Excel 97) and it ran just fine.

If you want, send me the workbook this fails on, and let me know what
range is selected when the macro starts. I'll see if I can find the
problem.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Ed" wrote in message
...
I wrote this on my machine running Win XP and XL2002. It worked. I gave
it to a friend running Win2000 and XL2000, and it fails on the code to
delete the initial series. What else can we do?

Ed

Sub MakeNewScatterChart()

Dim wkb As Workbook
Dim wks As Worksheet
Dim LastRow As Long
Dim LastCol As Long
Dim colData As Long
Dim cht As Chart
Dim chtObj As ChartObject
Dim rngData As Range
Dim rngXval As Range
Dim rngSer As Range
Dim strTitle As String

' Get limits of data
Set wkb = ActiveWorkbook
Set wks = wkb.Sheets(1)
LastRow = wks.Range("A65536").End(xlUp).Row
LastCol = wks.Range("IV4").End(xlToLeft).Column

' Set data range
Set rngData = wks.Range(Cells(4, 1), Cells(LastRow, LastCol))

' Define X data range
Set rngXval = rngData.Columns(1)

For colData = 2 To LastCol
' Add new chart object
Set cht = wkb.Charts.Add
With cht
.ChartType = xlXYScatterSmoothNoMarkers

''' *** ERROR HERE ***
' Delete initial data series
Do While .SeriesCollection.Count 0
.SeriesCollection(1).Delete
Loop








All times are GMT +1. The time now is 11:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com