本文介绍了VBA删除图表系列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的图表包含一些无关紧要的系列。这些系列都在其中包含单词 series(例如 Series1, Series2),而不是描述性名称。

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

有人可以提供VBA程序来执行此伪代码:

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


推荐答案

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.

这篇关于VBA删除图表系列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 16:33