Setting Axis scale

R

Robin Clay

Greetings !

When I address a different data file, I have code to
generate a chart to display the new data.

For some s t r a n g e reason, the code SOMETIMES comes
to a grinding halt at this line -

.SeriesCollection(4).XValues = _
"=Ali2!R" & VTPStartRow & _
"C2:R" & VTPEndRow & "C2"

VTPStartRow has a value of say 80, and VTPEndRow about
100, and it works just FINE if I enter them "manually".

It never stops anywhere else, always at this line ! But
sometimes it works OK....
 
J

Jon Peltier

Robin -

Before you get to this line, is the series formula valid? If the series
has no plottable data (all blanks or error values, for instance), you
will not be able to access or edit the series formula or its constituent
parts (like the XValues).

Rumor has it, and I have not extensively tried this workaround, that
changing the series to an area type will enable you to access the series
formula in such a case. Then when the series is appropriately
populated, you can revert to your original chart type.

- Jon
 
J

Jon Peltier

Oh, absolutely ! It starts off with a previous (working)
value, then calculates a new one, and then tries
to "insert" it into the Chart.

It grinds to a halt, and the values are there in
the "Locals" window, and I can then use these to insert
the figures manually, whereupon it works OK.

However.... it frequently just keels over at that point !
The Chart appears with a hatched box round it, and then
Bingo ! Excel crashes....

But it is ALWAYS at that particular line ! It works FINE
for the other Series...

Sounds like a classic crash, all right.

I made your code work fine in a dummy worksheet. I wonder whether your
own workbook may be getting corrupt. Can you build a new workbook that
has your data and chart, then test it again?
You've lost me ... :(

This is what I meant:

With ActiveChart.SeriesCollection(1)
myType = .ChartType
.ChartType = xlArea
.Values = _
"=Ali2!R" & VTPStartRow & _
"C2:R" & VTPEndRow & "C2"
.ChartType = myType
End With

Can't promise anything, and since your series formula is valid before
this happens, it probably won't help.

- Jon
 

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