How can I get underlying range when Series Formula is longer than 255characters?

A

Alok

I am trying to write a macro that will navigate to the range that a
series represents. I do this by parsing Series.Formula. however, if
the Series.formula is longer than 255 chars, it gets truncated. Is
there any way to get the range in a situation like this? Here is some
code that generates a problem chart:

Sub CreateChartWithTrickyFormula()
'
' Macro2 Macro
' Macro recorded 12/4/2007 by saldanha
'

Range("A1:A34").FormulaR1C1 = "=RAND()"
Range("C1:C34").FormulaR1C1 = "=RAND()"
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SeriesCollection(1).XValues = _

"={38408,38436,38467,38497,38528,38558,38589,38620,38650,38681,38711,38742,38773,38801,38832,38862,38893,38923,38954,38985,39015,39046,39076,39107,39138,39166,39197,39227,39258,39288,39319,39350,39380,39411,39441,39472,39503}"
ActiveChart.SeriesCollection(1).Values = "=Sheet1!R1C1:R34C1"
ActiveChart.SeriesCollection(1).Name = _
"=""BigLongChartSeriesThatWillOverFlowWhenGottenAsFormula"""
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = _
"BigLongFormulaThatWillOverflowWhenGottenAsProperty"
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
End Sub

If you now type the following in the immediate window, you will find
that the formula is 255 chars, and does not contain the range
R1C1:R34C1

?len(activechart.SeriesCollection.item(1).formula)
?activechart.SeriesCollection.item(1).formula
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top