LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.charting
Lead Foot
 
Posts: n/a
Default Problem setting SeriesCollections source range

In VB6 sp4, I'm having problems setting the SeriesCollection() range. The
end row of the range will be dependent on the number of bins the user
declares so will always be variable. I've created a macro in Excel to use as
a guideline, but have had little luck with it. The chart will have 4
SeriesCollections one of which should only be visible/used for the XValues.
Dimming the strRange1 and strRange2 as Objects and using the Set statment to
define them stops compiling at the start of the Sub. Perhaps I'm using the
Set statment incorrectly. Dimming the strRange1 and strRange2 as xlLineChart
gives a message that "Compile Error: user-defined type not defined". I've
tried so many different ways of getting this to work, I've lost count and by
now I have a real mess. I'm really hoping someone out there can help.

Dim xlApp As Excel.Application
Dim xlWkBook As Excel.Workbook
Dim xlWkSheet As Excel.Worksheet
Dim xlLineChart As ChartObject

Set xlApp = New Excel.Application
Set xlWkBook = xlApp.Workbooks.Add

Dim strRange1 As String
Dim strRange2 As String
Dim varSeriesRange As Variant

eRows = 9 'start row for data output
NumLags = Val(txtLag.Text) 'assigns user input # of bins
intEnd = eRows + (NumLags * 2) 'end row for data output

strRange1 = "A" & eRows & ":A" & intEnd
strRange2 = "B" & eRows & ":B" & intEnd

varSeriesRange = "=R9" & "C1" & ":R" & intEnd & "C1"

Set xlLineChart = ActiveSheet.ChartObjects.Add(230, 100, 400, 250)
xlLineChart.Activate
xlLineChart.Chart.ChartType = xlLineMarkers
With xlLineChart.Chart
.SetSourceData ActiveSheet.Range(strRange1, strRange2)
.SetSourceData Range(strRange1, strRange2), .PlotBy = xlColumns

'*****Compiles to here then error 438 - Object doesn't support
'*****This doesn't work even hard coding the source range

.SeriesCollection(2).Add ActiveSheet.Range(strRange2) '("b9:b29")

.SeriesCollection(1).XValues = varSeriesRange '"=R9C1:R29C1"
End With

 
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
VBA setting range in another sheet Jeff Excel Discussion (Misc queries) 2 October 14th 05 02:11 PM
Setting dynamic range in a formula Phillycheese5 Excel Worksheet Functions 9 June 10th 05 07:58 PM
Defined range problem Pat Excel Discussion (Misc queries) 8 January 17th 05 11:25 AM
Dynamic Range Problem [email protected] Excel Discussion (Misc queries) 4 January 4th 05 06:55 PM
Excel 97 chart opened in Excel 2003 - Source Data problem DHunt Charts and Charting in Excel 0 December 6th 04 08:05 PM


All times are GMT +1. The time now is 07:36 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"