ajwillshire
New Member
- Joined
- Mar 4, 2009
- Messages
- 31
Hi,
I've got a macro which creates dynamic ranges and adds them to a chart. As part of it a User Form offers the chance to prefix the Dynamic Name before charting.
However, if I use a prefix beginning with R or C it falls over. I know that R or C followed by an integer is forbidden but as far as i can see that doesn't occur.
Here's the line which trips it up:
ActiveChart.SeriesCollection.NewSeries.Formula = "=SERIES(" & Chr(34) & mySeriesName & Chr(34) & "," & wksName & "!" & Prefix_ns & "Dates," & wksName & "!" & myName & "," & i & ")"
mySeriesName is the name that appears in the legend - say "October Spend".
wksName is the worksheet name - "Sheet2" in my example
Prefix_ns is the prefix e.g., "Roger_"
myName is the name of the dynamic range - "October_Spend"
i is the index of the loop to give the series number in the chart.
So the formula that it should be is
"=Series("October Spend", 'Sheet2'!Roger_Dates, '"Sheet2'!Roger_October_Spend, 1)
But it doesn't work if the prefix begins with R or C, So Roger, Rhys, Colin, etc all trip it up while all other names work perfectly.
Any ideas?
Thanks in advance,
Andrew
I've got a macro which creates dynamic ranges and adds them to a chart. As part of it a User Form offers the chance to prefix the Dynamic Name before charting.
However, if I use a prefix beginning with R or C it falls over. I know that R or C followed by an integer is forbidden but as far as i can see that doesn't occur.
Here's the line which trips it up:
ActiveChart.SeriesCollection.NewSeries.Formula = "=SERIES(" & Chr(34) & mySeriesName & Chr(34) & "," & wksName & "!" & Prefix_ns & "Dates," & wksName & "!" & myName & "," & i & ")"
mySeriesName is the name that appears in the legend - say "October Spend".
wksName is the worksheet name - "Sheet2" in my example
Prefix_ns is the prefix e.g., "Roger_"
myName is the name of the dynamic range - "October_Spend"
i is the index of the loop to give the series number in the chart.
So the formula that it should be is
"=Series("October Spend", 'Sheet2'!Roger_Dates, '"Sheet2'!Roger_October_Spend, 1)
But it doesn't work if the prefix begins with R or C, So Roger, Rhys, Colin, etc all trip it up while all other names work perfectly.
Any ideas?
Thanks in advance,
Andrew