Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA Chart 1

Status
Not open for further replies.

adamsr

Technical User
Dec 2, 2002
6
0
0
US
What is the right code in Excel VBA to move the chart "source data" one column to the right each time the macro runs?
Thanks
 
You have to access the chart.seriescollection(1).formula property.
Then parse the string to find the data column, and increment the column number. Remake the string, and reassign the formula property. You can use something like

s=activechart.SeriesCollection(1).formula
p1=instrrev(s,"!")
p2=instrrev(s,",")
set cell=sheets("MyData").range(mid(s,p1+1,p2-p1-1)).offset(0,1)
activechart.SeriesCollection(1).formula=left(s,p1)+cell.address+mid(s,p2)


Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top