4d554d424c4553
4d554d424c4553

Reputation: 95

Move Chart series data via VBA

I have the following code

Dim ss As Series
Dim strs() As String
Set ss = ActiveChart.SeriesCollection(1)
strs = Split(ss.Formula, ",")
Dim rg As Range
Set rg = Range(strs(2))
Set rg = rg.Resize(rg.Rows.Count + 1)
ActiveChart.SeriesCollection(1).Values = rg

This allows me to add 1 more item of data to my data series but I want it to also remove the 1st entry every time I run it. For example Day 1- range is A1 to C1 then I run the macro I want it to go to B1 to D1

I hope this makes sense

Upvotes: 1

Views: 1467

Answers (1)

David Zemens
David Zemens

Reputation: 53653

This will "move" the range, rather than resizing it, which is what you're doing.

Set rg = rg.Offset(1,0)

Upvotes: 2

Related Questions