Range("cell").Select Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The following code no longer works for 11 of my 12 worksheets:

Sub Testing()
Sheets(1).Range("A50").Select
End Sub

If I record a new macro and select any cell in any sheet, the above code is
created. (With appropriate sheets and cell names.) The code works as long
as it stays in the Module it was created in. If I copy and paste the code
into a worksheet, it gives the error: "Run-time error '1004':
Application-defined or object-defined error".

For some reason, If I reference sheet 2 in the above code, the code can be
placed in any worksheet and it will work. That isn't true for any other
sheet however.
Any ideas? Thanks.
 
It'll only work when Sheets(1) is the activesheet.

You can only select a cell on an activesheet.

Sub Testing()
sheets(1).select
Sheets(1).Range("A50").Select
End Sub

will fix it.
 
Wow. I don't know how I missed that. Thanks.

Dave Peterson said:
It'll only work when Sheets(1) is the activesheet.

You can only select a cell on an activesheet.

Sub Testing()
sheets(1).select
Sheets(1).Range("A50").Select
End Sub

will fix it.
 

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

Back
Top