Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default different value for setting with breakpoint vs regular running code

I'm creating a chart with two data series using vba. One data series is on the primary axis and one is on the secondary axis. In order for the chart to look correct, the two axis need to have the same max/mins. I have written code that does just this. Below is a portion of code from a much larger routine.

With ActiveChart.Axes(xlValue, xlSecondary)
.MinimumScale = ActiveChart.Axes(xlValue, xlPrimary).MinimumScale
.MaximumScale = ActiveChart.Axes(xlValue, xlPrimary).MaximumScale
End With

In my testing I'm using a chart with primary axis max=60, min=-30. The code always works for the maximum value. It also works perfectly for the min if I put a breakpoint in the code before "MinimumScale = ActiveChart....". However, if the code is called from Excel and runs freely (no breakpoints), or if the first breakpoint is after "MinimumScale = ActiveChart...", then VBA somehow concludes that the min=-40.

I'm finding this absolutely maddening. Does anyone know how to get Excel/VBA to work correctly?

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default different value for setting with breakpoint vs regular running code

Just a thought, and of course I maybe way off the mark if comprehending your
request.

Would a "Select Case" be of help, something along the lines like:

If Not ("MyCondition") Is Nothing Then

Select Case True

Case (MyCondition_1)

With ActiveChart.Axes(xlValue, xlSecondary)
.MinimumScale = ActiveChart.Axes(xlValue,
xlPrimary).MinimumScale
.MaximumScale = ActiveChart.Axes(xlValue,
xlPrimary).MaximumScale
End With

Case (MyCondition_2)

With ActiveChart.Axes(xlValue, xlPrimary)
.MinimumScale = ActiveChart.Axes(xlValue,
xlSecondary).MinimumScale
.MaximumScale = ActiveChart.Axes(xlValue,
xlSecondary).MaximumScale
End With

End Select
End IF

HTH
Mick


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 230
Default different value for setting with breakpoint vs regular running code

On Mar 2, 11:35*am, daddy-o wrote:
I'm creating a chart with two data series using vba. *One data series is on the primary axis and one is on the secondary axis. *In order for the chart to look correct, the two axis need to have the same max/mins. *I have written code that does just this. *Below is a portion of code from a much larger routine.

With ActiveChart.Axes(xlValue, xlSecondary)
* * .MinimumScale = ActiveChart.Axes(xlValue, xlPrimary).MinimumScale
* * .MaximumScale = ActiveChart.Axes(xlValue, xlPrimary).MaximumScale
End With

In my testing I'm using a chart with primary axis max=60, min=-30. *The code always works for the maximum value. *It also works perfectly for the min if I put a breakpoint in the code before "MinimumScale = ActiveChart...". *However, if the code is called from Excel and runs freely (no breakpoints), or if the first breakpoint is after "MinimumScale = ActiveChart...", then VBA somehow concludes that the min=-40.

I'm finding this absolutely maddening. *Does anyone know how to get Excel/VBA to work correctly?


Avoid using XL2007. Failing that add a delay after creating the chart
and before altering the Axes.

It is one of many race conditions in the XL2007 graphics and charting
code and can probably be kludged around by adding a judicious delay in
the right place. It probably explains why it runs with such glacial
slowness too since MS have doen the same fix internally in their own
code. If you try really hard with big datasets you can write VBA code
that attempts to modify the axes even before they have been
instantiated and fully initialised failing object not found. The debug
breakpoint suspends the main thread execution for long enough to allow
the Axis object to become correctly created and initialised. Whoever
wrote the XL2007 charts code should be terminated. Their attempt to
parallelise things to speed it up backfired big time.

You can also get another situation where chart dialogues invoked from
VBA return the original values immediately with a "done" flag but
remain active and allow the user to alter things whilst the program
remains blissfully unaware of it! These race conditions tends to be
worst on fast machines with multiple cores. I am now seeing new
"features" that only cause trouble on quad core and higher.

Regards,
Martin Brown
Reply
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
Code stops for one user, like it has a breakpoint Barb Reinhardt Excel Programming 1 December 18th 09 05:09 AM
Setting timer to run macro at regular intervals JLGWhiz Excel Programming 0 January 10th 09 06:05 PM
Setting timer to run macro at regular intervals Mike H Excel Programming 0 January 10th 09 05:18 PM
need breakpoint to stop code Souris Excel Programming 1 February 22nd 08 07:00 PM
Ignore breakpoint when running a macro hmm Excel Programming 5 January 1st 08 12:51 PM


All times are GMT +1. The time now is 04:58 PM.

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"