excel - VBA updating data series forumla changing formatting -


i'm having unexpected issue code. it's suppose update 2 data series of chart object dynamically. i've added series collection(a total of 3 series now). data series update problem formatting 3 series swap around between each other every time update occurs. here code below updating occurs:

dim wrksheet string wrksheet = application.worksheets(x).name  if background > 0     'update background data series     application.worksheets(x).chartobjects("main chart").chart.seriescollection(2).formula = _     "=series(""background"",('" & wrksheet & "'!$j$32:$j$" & (32 + background - 1) & ",'" & wrksheet & "'!$j$" & backgroundstart2 & ":$j$" & (backgroundstart2 + background - 1) & ")," _     & "('" & wrksheet & "'!$k$32:$k$" & (32 + background - 1) & ",'" & wrksheet & "'!$k$" & backgroundstart2 & ":$k$" & (backgroundstart2 + background - 1) & "),2)" else     'make application not graph background in scenario end if  'update peak data series application.worksheets(x).chartobjects("main chart").chart.seriescollection(1).formula = _ "=series(""peak"",'" & wrksheet & "'!$j$" & (peakstart1) & ":$j$" & peakend1 & ",'" & wrksheet & "'!$k$" & peakstart1 & ":$k$" & peakend1 & ",1)"  'update peak background data series application.worksheets(x).chartobjects("main chart").chart.seriescollection(3).formula = _ "=series(""step background"",'" & wrksheet & "'!$j$" & (peakstart1) & ":$j$" & peakend1 & ",'" & wrksheet & "'!$o$" & peakstart1 & ":$o$" & peakend1 & ",1)" 

once code completes, each of 3 series collection objects update correctly associated formatting each changes. believe series collection may deleted , recreated removing formatting, i'm unsure why case. great.

the final parameter of series call index order. have 2 entries 1 , first 1 has 2. displacing each other go. should number in order (same order spot in seriescollection).

code shows changing last formula appears errant one.

"=series(""step background"",'" & wrksheet & "'!$j$" & (peakstart1) & ":$j$" & peakend1 & ",'" & wrksheet & "'!$o$" & peakstart1 & ":$o$" & peakend1 & ",3)" 

note changed last row 1 3 match seriescollection(3)

excellent reference on series formula. http://peltiertech.com/excel/chartshowto/chartseriesformula.html


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -