Thread: Selecting
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Selecting

Worksheets("PositionImports").Select
Worksheets("PositionImports").Range("Positions").S elect

Assumes Range("Positions") is on Sheet PositionImports.

I assume you are running this with a command button or in any event the code
is in a sheet module. In such cases, the unqualified Range("Positions") is
implicitly qualified by the sheet containing the code module. Since it is
not on that sheet, you get the error. Explicitly qualifying it removes that
problem.

--
Regards,
Tom Ogilvy



"Mark Petruszak" wrote in message
...
Hopefully someone will clarify an issue for me that has me baffled. This

is
not the first time that selection of a range in another worksheet

generates
errors. I want to select a range in another worksheet. Excel keeps

giving
me a run time error '1004'.

These errors occur even if I fully qualify the name, such as
Worksheets("PI").Range("P").Select. I also recorded a macro to see what

it
generated for code, then copied that and still received the error.

This is the code that I am using currently:

Worksheets("PositionImports").Select
Range("Positions").Select

This is the error with the Range select line highlighted in the IDE:

Run time error '1004'

Method 'Range' of object '_Worksheet' failed.


What gives here? Excel seems to not deal with this issue in a consistent
manner.

Thank you,
Mark