This does not work: Range("A1").Select

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

Why do I get an error with this?


Private Sub CommandButton1_Click()
Sheets("Forecast").Select
Range("A1").Select
End Sub
 
Hi

Probably because that code is in Sheet3. From there you have very limited power over
Sheet1. Put code like this in standard modules and call them from the sheets. Like:

Sub GoForecast()
Sheets("Forecast").Select
Range("A1").Select
End Sub

and in the sheet:

Private Sub CommandButton1_Click()
Call GoForecast
End Sub
 
Private Sub CommandButton1_Click()
Sheets("Forecast").Select
Range("A1").Select
End Sub

Because the unqualified Range("A1").Select refers to the sheet containing
the button which is not the active sheet

Private Sub CommandButton1_Click()
With Sheets("Forecast")
.Select
.Range("A1").Select
End Sub


Should work.
 

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


Back
Top