VBA deleting chart series [closed]

人盡茶涼 提交于 2019-12-14 00:08:50

问题


My chart contains some extraneous series. These series all contain the word "series" in them (e.g., "Series1", "Series2") rather than descriptive names.

Can someone please provide a VBA procedure that executes this Pseudocode:

In chart 1 if any series name contains the word "series" delete it.
If not then do nothing


回答1:


Sub DeleteSeriesWith_Series_InName()
  Dim iSrs As Long
  With ActiveChart
    For iSrs = .SeriesCollection.Count To 1 Step -1
      If InStr(LCase$(.SeriesCollection(iSrs).Name), "series") > 0 Then
        .SeriesCollection(iSrs).Delete
      End If
    Next
  End With
End Sub

Count series backwards, because deleting a series changes the series numbers of any series after it.



来源:https://stackoverflow.com/questions/24661467/vba-deleting-chart-series

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!