Sub A1 Line Malfunction

P

Phil Hageman

The Sub below is attached to a forms control button, and
the line Range ("A1").Select is not working. Can someone
help correct this?

Sub GoToMetric1()
Application.ScreenUpdating = False
Sheets("Metrics").Select
Range("A1").Select
ActiveWindow.Zoom = 57
With ActiveSheet.ChartObjects("Chart 13")
.Height = 660
.Width = 780
.Top = 10
.Left = 125
.BringToFront
End With
Application.ScreenUpdating = True
End Sub
 
V

Vasant Nanavati

Why something "is not working" is almost always impossible to diagnose.
Would you care to share some details? What happens? Is there an error
message? If so, what is it? If not, does the rest of the Sub continue? Do
you have the code in a standard module? And why do you want to select A1
anyway?
 
D

Dave Peterson

Is your code in a General module--or under a worksheet?

(Try putting it in a general module if it's not there already.)
 
D

Dave Peterson

And just to add, if it's under a worksheet module, then this line:
Range("A1").Select
has a problem.

Range("a1") is an unqualified reference. In a general module, it'll refer to
the activesheet. But behind a worksheet, it refers to the sheet containing the
code.

And you can't select a range on a sheet that isn't active. (and Metrics is the
active sheet).
 

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