View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Peter Huang [MSFT] Peter Huang [MSFT] is offline
external usenet poster
 
Posts: 225
Default Macro to automatically move chart data

Hi

Here is the macro which will resize the serises by one row per time we run
the macro.

Hope this helps.

Sub Test()
Sheet1.ChartObjects("Chart 1").Activate
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

Set ss = ActiveChart.SeriesCollection(2)
strs = Split(ss.Formula, ",")
Set rg = Range(strs(2))
Set rg = rg.Resize(rg.Rows.Count + 1)
ActiveChart.SeriesCollection(2).Values = rg
End Sub

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.