LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
jonwatts
 
Posts: n/a
Default Dynamic Chart Generation


I am trying to use VBA to dynamically produce a number of charts. The
number of charts produced depends on the amount of data that appears in
a seperate spreadsheet...

I have taken the code produced when I recorded a macro to produce one
such chart and adapted it to meet my needs, however I am getting error
1004, "Unable to set the XValues property of the Series class" when I
try to assign the x-axis values using a range I have dynamically
created.

I'm sure the problem is somewhere with my syntax, but however I try to
phrase it I cannot seem to get it to work.

Please find a copy of my code below - any help would be much
appreciated!

Jon

In the following code the variable Count determines how many charts
will need to be produced:

<code
Dim i As Integer
Dim Count As Integer
Dim intGraphDisplayStartRow As Integer
Dim rngTempRange1 As Range
Dim rngTempRange2 As Range
Dim rngTempRange3 As Range


If Count 0 Then
For i = 1 To Count
intGraphDisplayStartRow = (i * 13) + 2
ThisWorkbook.Worksheets("Page 2").Select

Charts.Add
Set rngTempRange1 =
ThisWorkbook.Worksheets("WorkspaceTemp") _
.Range("A" & Trim(CStr(intGraphDisplayStartRow _
& ":A" & intGraphDisplayStartRow + 11)))
Set rngTempRange2 =
ThisWorkbook.Worksheets("WorkspaceTemp") _
.Range("C" & Trim(CStr(intGraphDisplayStartRow)) & ":C"
_
& Trim(CStr(intGraphDisplayStartRow + 11)))
Set rngTempRange3 =
ThisWorkbook.Worksheets("WorkspaceTemp") _
.Range("C" & Trim(CStr(intGraphDisplayStartRow - 1)))

ActiveChart.ChartType = xlLine
ActiveChart.SeriesCollection(1).XValues = rngTempRange1
ActiveChart.SeriesCollection(1).Values = rngTempRange2
ActiveChart.SeriesCollection(1).Name = rngTempRange3
ActiveChart.Location Whe=xlLocationAsObject, Name:="Page
2"

Next
End If
</code


--
jonwatts
------------------------------------------------------------------------
jonwatts's Profile: http://www.excelforum.com/member.php...o&userid=28038
View this thread: http://www.excelforum.com/showthread...hreadid=475451

 
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
Activating a Chart object Hari Prasadh Charts and Charting in Excel 6 August 2nd 05 07:22 PM
Dynamic bar chart, must ignore "n/a" data... paris3 Charts and Charting in Excel 4 June 26th 05 07:07 PM
dynamic end on chart Donna YaWanna Charts and Charting in Excel 1 June 17th 05 04:50 PM
how to change range for dynamic chart in excel 2000 with button? ivan Charts and Charting in Excel 2 April 24th 05 04:10 AM
dynamic chart with scroll bar tiw Excel Discussion (Misc queries) 0 April 21st 05 03:43 PM


All times are GMT +1. The time now is 10:04 PM.

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"