Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
CWillis
 
Posts: n/a
Default Range("cell").Select Problem

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.
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default Range("cell").Select Problem

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.


CWillis wrote:

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.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
CWillis
 
Posts: n/a
Default Range("cell").Select Problem

Wow. I don't know how I missed that. Thanks.

"Dave Peterson" wrote:

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.


CWillis wrote:

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.


--

Dave Peterson

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
have some problem with database baldamenti Excel Discussion (Misc queries) 1 October 13th 05 05:38 PM
Urgent Help Required on Excel Macro Problem Sachin Shah Excel Discussion (Misc queries) 1 August 17th 05 06:26 AM
Problem With Reference Update Egon Excel Worksheet Functions 17 July 16th 05 05:45 AM
Copy an Drag cell Formula Problem Nat Excel Discussion (Misc queries) 1 June 20th 05 03:24 PM
Freeze Pane problem in shared workbooks JM Excel Discussion (Misc queries) 1 February 1st 05 12:04 AM


All times are GMT +1. The time now is 09:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"