LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 152
Default For Each srs in cht.seriescollection not working

Hi,
I have a very complex chart with about 400 lines on X-Y chart.
The issue is that not all the series have the same range as the "XValue" so
if I autofilter the data, it hides the Xvalue range on some series and so it
doesn't scale hte X-Axis correctly.

Because if this, I want to search through all the series where the data
comes from a worksheet with "data" in the name. Find the series that has the
"xValue" row at the top of the page and then set all the other data series
X-Values to the one at the top of the row.

Not all series point to the same data worksheet and there could be other
issues (I didn't build the chart).

Any help would be great!

Dim rngDataSource As Range
Dim iDataRowsCt As Long
Dim iDataColsCt As Integer
Dim iSrsIx As Integer
Dim chtChart As Chart
Dim srsNew As Series
Dim rngXVal As Range
Dim addXVals
Dim dataSheetName
Dim topXval
Dim thisXvalRow
Dim sCount

dataSheetName = "data"
topXval = 1000
Application.ScreenUpdating = False
Set cht = ActiveChart
If cht.ChartType = 0 Then Exit Sub

For Each srs In cht.SeriesCollection

addXVals = Extract_Series_Ranges(srs.FormulaR1C1, "X")

If InStr(1, srs.Name, "ARC") = 0 And InStr(1, srs.Name, "RIM") =
0 Then
If InStr(1, addXVals, dataSheetName) 0 Then
thisXvalRow = Range(addXVals).Row
If thisXvalRow < topXval Then
topXval = thisXvalRow

End If

End If

End If

Next
Application.ScreenUpdating = True


End Sub


Private Function Extract_Series_Ranges(SerForm, XorY)
Dim comma1, comma2, comma3, comma4
Dim xRange
Dim yRange
Dim nRange
Dim par1
Dim Ord

par1 = InStr(1, SerForm, "(")
comma1 = InStr(1, SerForm, ",")
comma2 = InStr(comma1 + 1, SerForm, ",")
comma3 = InStr(comma2 + 1, SerForm, ",")
comma4 = InStr(comma3 + 1, SerForm, ",")

nRange = Mid(SerForm, par1 + 1, comma1 - par1 - 1)
xRange = Mid(SerForm, comma1 + 1, comma2 - comma1 - 1)
yRange = Mid(SerForm, comma2 + 1, comma3 - comma2 - 1)
Ord = Mid(SerForm, comma3 + 1, Len(SerForm) - comma3 - 1)

Select Case XorY
Case "X"
Extract_Series_Ranges = xRange
Case "Y"
Extract_Series_Ranges = yRange
Case "Name"
Extract_Series_Ranges = nRange
Case "Ord"
Extract_Series_Ranges = Ord
End Select


End Function
 
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
seriescollection(name) not working in excel 2007 bucweat Excel Programming 5 March 22nd 08 03:53 AM
.SeriesCollection(2).Name and .Deselect Peter Sie Charts and Charting in Excel 2 July 3rd 06 03:10 AM
SeriesCollection Varun[_2_] Excel Programming 1 July 28th 04 01:49 AM
VBA- SeriesCollection(1).Value error crossplatform Excel Programming 3 April 12th 04 04:27 PM
VBA- SeriesCollection yusoon[_3_] Excel Programming 1 April 8th 04 10:38 AM


All times are GMT +1. The time now is 08:49 AM.

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"