Thread: Range error
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Barb Reinhardt Barb Reinhardt is offline
external usenet poster
 
Posts: 3,355
Default Range error

I'd probably get rid of the SELECT altogether

Dim myWS as Worksheet
Dim myRange as range

On Error resume next
Set myWS = Sheets("Name")
On error goto 0
if myWS is nothing then
MsgBox("There is no worksheet 'Name'.")
End
end if

Set myRange = myWS.Range("A2:D26")

Do all of your action on myRange.
--
HTH,
Barb Reinhardt



"Murray" wrote:

I have an error occuring when I try to run this simple bit of code. The code
is:

Sheets("Name").select
Range("A2:D26").select

The code is started on Sheet1 and it does change to "Name" but it says :
select method of Range class failed.
The code is assigned to a button.

Any ideas what I have done wrong
Thanks in advance