Furtive Bug!

P

Phil Hageman

On different worksheets are (Forms) Buttons with the below
macros assigned to them. "GoToUtilizationChart()" works
perfectly, but "GoToPPVChart()" only brings up
the "Metrics" worksheet and cursors to A1 - it does not
select the chart. Chart names are confirmed correct. To
test the problem, I copy/pasted the "Utilization" macro
and substituted "PPV" and "3" in the code - still doesn't
select the PPV chart. Can someone help me exterminate
this bug?!

Appreciate any help...
Phil


Sub GoToPPVChart()
Sheets("Metrics").Select
Range("A1").Select
With ActiveSheet.ChartObjects("Chart 13")
.Height = 660
.Width = 780
.Top = 10
.Left = 125
End With
End Sub

Sub GoToUtilizationChart()
Sheets("Metrics").Select
Range("A1").Select
With ActiveSheet.ChartObjects("Chart 17")
.Height = 660
.Width = 780
.Top = 10
.Left = 125
End With
End Sub
 
T

Tushar Mehta

Nothing in the code attempts to select any chart. So, I'm at a loss as
to why you expect a chart to be selected.

Is the chart the correct size and at the correct location after the
macro finishes?

Do you have any error handling enabled? If so, disable it.

--
Regards,

Tushar Mehta, MS MVP -- Excel
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 
P

Phil Hageman

Tushar, Thanks for your replay.
Maybe "select" is the wrong term. When the button is
clicked, the "Metrics" worksheet should comes on screen,
the cursor should go to A1, and the chart called for in
the macro should become current, sized, and move to the
Top/Left position. In this problem, the "Utilization"
chart is performing exactly this way; but the "PPV" chart
doesn't resize or position. Is there another way to get
the desired result? No error handling is enabled.
 
J

Jon Peltier

Phil -

I just tried your procedures with two charts (13 & 17), without changing
a bit of the code. Both worked fine, as I expected, with the sheet
unprotected and protected. How did you verify the chart names? Run
this short program:

Sub ListCharts()
Dim msg As String
Dim chtob As ChartObject
msg = ActiveSheet.Name & vbCrLf
For Each chtob In ActiveSheet.ChartObjects
msg = msg & vbCrLf & chtob.Name
Next
MsgBox msg
End Sub

It should give you this (and more if there are more charts):

Metrics

Chart 13
Chart 17

What do you get?

- Jon
 
P

Phil Hageman

Jon, the message box came up with:
Chart 13
Chart 17
Chart 33
Chart 36
Tell you what, let me play with this some more and get
back to you. I have two versions of this code which work
(both on my threads in this NG). This problem seems
intermittant and must be coming from another area of the
workbook. I will post tomorrow if I run into trouble...

Thanks for all your help. Phil
 
J

Jon Peltier

Phil -

Okay, now we're down to basics. Restart Excel, and see if it works.
Copy the charts to another sheet, and see if it works. Rebuild the
charts in a new workbook, and see if it works. Trade in your balky old
monster for a sleek new laptop, and see if it works. That last step
might be a bit extreme, but I am beginning to suspect that your workbook
is becoming corrupt.

Another thing: it's possible to put additional layers of protection on a
chart. Some of these would interfere with the code. But you need VBA
to do it, so you'd probably remember that you'd done such a thing.

- 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

Similar Threads

Funny macros 2
Chart Activate Problem 3
Sub A1 Line Malfunction 3
Macro Line Inoperative 2
Add Formatting Code in Macro 1
Run-time error on command button 4
Code Modification 4
secondary Y axis 1

Top