Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.charting
|
|||
|
|||
![]()
I have a chart, created by an Excel macro, with data derived from a
named sheet. I'm trying to modify that chart in VBA to reference a different sheet with a different number of lines. Simple enough, except that the chart has custom error bars, and there appears to be no way to retrieve the formula associated with those error bars. Excel obviously keeps a formula for these error bars - I can see it through "Format Error Bars" in the UI - but I don't see it anywhere in a watch. Anyone know how I can get to - and modify - the formula for error bars? Here's my code thus far: Option Explicit Const SEARCH_DIR = "F:" Public Sub Weekly_Charts() Dim wb As Workbook Dim sh As Variant Dim cht As ChartObject Dim ser As Series Dim strFormula As String Dim i As Integer Dim j As Integer Dim iDayRows As Integer Dim iWeekRows As Integer Dim errb As ErrorBars Set wb = Workbooks.Open(SEARCH_DIR & "base_n_year_by_province_2008.xls") For Each sh In wb.Sheets Select Case sh.Name Case "Data_Sheet" iDayRows = sh.UsedRange.Rows.Count Case "Weekly_Data" iWeekRows = sh.UsedRange.Rows.Count End Select Next sh For Each sh In wb.Sheets Select Case sh.Name Case "Data_Sheet" Case "Weekly_Data" Case Else Set cht = sh.ChartObjects(1) cht.Activate For Each ser In ActiveChart.SeriesCollection ser.Formula = WorksheetFunction.Substitute (ser.Formula, "Data_Sheet", "Weekly_Data") ser.Formula = WorksheetFunction.Substitute (ser.Formula, iDayRows, iWeekRows) If ser.HasErrorBars Then Set errb = ser.ErrorBars ' Now what??? End If Next ser sh.ChartObjects(2).Delete sh.ChartObjects(2).Delete End Select Next sh Workbooks.Close Set wb = Nothing End Sub (..and how come, if I define sh as Woksheet, I get a type mismatch on "For Each sh In wb.Sheets"??) |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to retrieve the values within cells? | Excel Discussion (Misc queries) | |||
need to retrieve data that was saved in error | Excel Discussion (Misc queries) | |||
How do I retrieve a file deleted in error? | Excel Discussion (Misc queries) | |||
Retrieve values from 2 worksheets. | Excel Worksheet Functions | |||
how do you retrieve a file that was overwritten in error? | Excel Discussion (Misc queries) |