View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Worksheets("MyName").select

Got it..........thanks IanKR

Vaya con Dios,
Chuck, CABGx3



"IanKR" wrote:

Having trouble here with the lines of code

Worksheets("MyName").select
and
Copy Destination:=Worksheets("MyName").Range("A1")

where MyName is a variable, declared and set earlier.......I get
"Runtime error 9, Subscript out of range" error and macro won't pass
that point.

How else might I be able to refer to that sheet whose name changes as
the macro goes along.......


If MyName is a variable, exclude the "" - viz:

Worksheets(MyName).select
and
Copy Destination:=Worksheets(MyName).Range("A1")