Worksheets("MyName").select

G

Guest

Hi All........

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.......

TIA
Vaya con Dios,
Chuck, CABGx3
 
N

Norman Jones

Hi Chuck,

Try deleting the quotes:

Worksheets(MyName).select

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

IanKR

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")
 
N

Nick

Hi All........

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.......

TIA
Vaya con Dios,
Chuck, CABGx3

Dont use quotes
 
G

Guest

True Tom.....LOL, but I spent a couple hours anguishing over that problem
before asking, and then it went so well with the "right" answer.......I just
love it when a plan comes together......I'd be in a heap of doo-doo with out
the help I get here.

Vaya con Dios,
Chuck, CABGx3
 

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

Top