Series name in chart is test. I want to delete the serie if "te" is part of the series name and tried following code, but it doesn't work.
ActiveSheet.ChartObjects("Chart 4").Activate
Dim n As Series
ActiveChart.PlotArea.Select
For Each n In ActiveChart.SeriesCollection
' If Right(.SeriesCollection.Name, 3) = "te" Then Doesn't work
' If n.Name = "*te*" Then Works with "test", but not with "te"
n.Delete
End If
Next n
CodePudding user response:
Read about the like-Operator (https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/like-operator) - you have to use it similar to the equal sign:
Dim n As Series
For Each n In ActiveChart.SeriesCollection
If n.Name Like "*te*" Then
n.Delete
End If
Next n
CodePudding user response:
Sorry, I'm a beginner. I tried Like, but that doesn't work As I have it now
Dim n As Series
ActiveChart.PlotArea.Select
For Each n In ActiveChart.SeriesCollection
If n.Like = "te" Then
n.Delete
End If
Next n