Home |
Search |
Today's Posts |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for the link! It gave me a couple ideas, but I went in another
direction. I wanted something more simple than what Module could accomplish. Here's my solution. It could be cleaned up a bit, but it seems to work. At the moment, there's no validation of movement. You could go outside the bounds of data, but that's an exercise for another day. I'm incrementing every chart by 1 row, because that's the structure of my data/charts. You could change the movement of the chart window as required. I'm open to any feedback. Thanks guys, you all helped a lot. Public Sub AdvanceChartData() Dim cht As Chart Dim sr As Series Dim i As Long, j As Long Dim arrFormula As Variant Dim curXValues As String, newXValues As String Dim curValues As String, newValues As String For i = 1 To ActiveSheet.ChartObjects.Count Set cht = ActiveSheet.ChartObjects(i).Chart For Each sr In cht.SeriesCollection arrFormula = Split(sr.Formula, ",") curXValues = arrFormula(1) curValues = arrFormula(2) newXValues = MoveDataRange(curXValues, 1) newValues = MoveDataRange(curValues, 1) sr.Formula = arrFormula(0) & "," & newXValues & "," & newValues & "," & arrFormula(3) Next Next End Sub Public Function MoveDataRange(strRange As String, lngMoveBy As Long) Dim loc As Long Dim locStartDS As Long Dim locColon As Long Dim locEndDS As Long Dim lngFromRow As Long Dim lngToRow As Long locStartDS = InStr(1, strRange, "$") locStartDS = InStr(locStartDS + 1, strRange, "$") locColon = InStr(locStartDS + 1, strRange, ":") lngFromRow = CLng(Mid(strRange, locStartDS + 1, locColon - (locStartDS + 1))) locEndDS = InStrRev(strRange, "$") lngToRow = CLng(Mid(strRange, locEndDS)) MoveDataRange = Mid(strRange, 1, locStartDS) & (lngFromRow + lngMoveBy) & Mid(strRange, locColon, (locEndDS + 1) - locColon) & (lngToRow + lngMoveBy) End Function -- Disregard, this is so I can find my post later. ***postedbyJay*** "Tom Ogilvy" wrote: http://j-walk.com/ss/excel/tips/tip83.htm that should help with the xValues, etc -- Regards, Tom Ogilvy "Jay" wrote: I found a small problem with this named range solution. I have 30+ charts I need to create named ranges for. With 3+ series in each chart. I think I might be farther ahead if I can find a way to modify the XValues and Values instead. That way it won't be dependant on the named ranges, and then I won't have to create them all. ;) Any ideas? -- Disregard, this is so I can find my post later. ***postedbyJay*** " wrote: One thing to note when using named ranges for chart series, ensure you name your range for the worksheet only and not the workbook. i.e. Sheet1!NamedRange Then when refering to the name range you will need to put Sheet1! NamedRange in the chart series. Regards, Toyin. ps - I hope you can find your post later! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
IF/COUNT/AVERAGE... Value returned is incorrect. | Excel Worksheet Functions | |||
F1 help for ChartObjects | Excel Programming | |||
ChartObjects | Excel Programming | |||
Datedif incorrect month count - February problem?? | Excel Worksheet Functions | |||
ChartObjects | Excel Programming |