LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 22
Default Retrieve Error Bar Values

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to retrieve the values within cells? Eric Excel Discussion (Misc queries) 6 September 14th 08 07:53 PM
need to retrieve data that was saved in error DD Excel Discussion (Misc queries) 2 September 10th 08 01:08 AM
How do I retrieve a file deleted in error? Laurie Excel Discussion (Misc queries) 3 July 9th 08 03:17 AM
Retrieve values from 2 worksheets. [email protected] Excel Worksheet Functions 3 May 24th 06 08:16 PM
how do you retrieve a file that was overwritten in error? FL Electra Excel Discussion (Misc queries) 3 November 14th 05 10:09 PM


All times are GMT +1. The time now is 04:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"