Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default Dynamic Range for a Chart & Trendline

Can anyone help? I have a pivot table of values that I am using in a chart. I
am using a lookup formula to have a range of 100 possible values within the
worksheet. Then I run this little "update" macro. I have an dynamic range for
the 100 possible values. =OFFSET(Repair Learning Curve Coeff!$G$4,0,0,COUNTA
(Repair Learning Curve Coeff!$G$4:$G$103),1)

I keep getting an error on the :=ActiveSheet.Range("ChartData") line of
'Runtime error 1004' Application-defined or object-defined error.

The range is still showing from G4:G103 (I assume it's from the dynamic range
formula?)

If I put the range of G4:G103 in the ActiveSheet.Range I get past the error
but then I will get a message for the trendline of "Some trendlines cannot be
calculated from data containing negative or zero values". Again it's because
the range is not changing for only those cells with values. Not sure how to
rewrite things.

Any ideas?

Sub Update()
'
Dim NbrRepairs As Range
Dim ChartData As String


' copy values outside of pivot to allow forumula's to calculate in learning
curve graphs
Columns("B:B").Select
Selection.Copy
Columns("C:C").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("D9").Select
Application.CutCopyMode = False

' Uppdate graph
Set NbrRepairs = Range("K52")
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartArea.Select

ActiveChart.SetSourceData Source:=ActiveSheet.Range("ChartData"), PlotBy:
=xlColumns

ActiveChart.Axes(xlCategory).Select
With ActiveChart.Axes(xlCategory)
.MinimumScaleIsAuto = True
.MaximumScale = NbrRepairs
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With

' Add Trendline
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection(1).Trendlines.Add(Typ e:=xlPower, Forward:=0,
_
Backward:=0, DisplayEquation:=True, DisplayRSquared:=True).Select
ActiveWindow.Visible = False
Windows("Repair Manpower 2008 b.xls").Activate
Range("V42").Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(1).Trendlines(1).Data Label.Select
Range("C4").Select
End Sub

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200808/1

Reply
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
dynamic range and chart - big help!! Xaraam Excel Worksheet Functions 3 August 4th 08 12:01 PM
Chart empty with new data in the dynamic range chart. Feejo Excel Discussion (Misc queries) 16 January 3rd 08 10:03 PM
dynamic chart range with VBA Jacob Excel Programming 6 September 25th 06 03:28 PM
Dynamic Range Chart ??? Yogalete Charts and Charting in Excel 3 April 27th 05 11:51 PM
Dynamic Chart Range and Chart Update ExcelMonkey[_154_] Excel Programming 1 July 6th 04 08:26 PM


All times are GMT +1. The time now is 08:15 PM.

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

About Us

"It's about Microsoft Excel"