Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default Worksheets("MyName").select

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Worksheets("MyName").select

Hi Chuck,

Try deleting the quotes:

Worksheets(MyName).select

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


---
Regards,
Norman


"CLR" wrote in message
...
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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Worksheets("MyName").select

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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Worksheets("MyName").select

On May 18, 11:07 am, CLR wrote:
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

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

So cool when you "know how"...<G

Thanks Norman

Vaya con Dios,
Chuck, CABGx3



"Norman Jones" wrote:

Hi Chuck,

Try deleting the quotes:

Worksheets(MyName).select

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


---
Regards,
Norman


"CLR" wrote in message
...
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







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



  #7   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 Nick

Vaya con Dios,
Chuck, CABGx3



"Nick" wrote:

On May 18, 11:07 am, CLR wrote:
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


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Worksheets("MyName").select

Not as exciting when you hear it the 3rd time <g

--
Regards,
Tom Ogilvy


"CLR" wrote:

Got it...........thanks Nick

Vaya con Dios,
Chuck, CABGx3



"Nick" wrote:

On May 18, 11:07 am, CLR wrote:
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


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

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







"Tom Ogilvy" wrote:

Not as exciting when you hear it the 3rd time <g

--
Regards,
Tom Ogilvy


"CLR" wrote:

Got it...........thanks Nick

Vaya con Dios,
Chuck, CABGx3



"Nick" wrote:

On May 18, 11:07 am, CLR wrote:
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


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
"Control" plus "click" doesn't allow me to select multiple cells Ken Cooke New Users to Excel 0 September 25th 06 04:46 PM
Problem: Worksheets("New Style 2006").Unprotect Password:="naPrint" Karoo News[_2_] Excel Programming 1 January 30th 06 02:40 PM
use variable in Workbooks("book1").Worksheets("sheet1").Range("a1" Luc[_3_] Excel Programming 2 September 28th 05 08:37 PM
IF(VLOOKUP("MYDATA", MYNAME, 4) = 0, "TRUE", "FALSE") Souris Excel Programming 2 August 17th 05 05:33 AM
Using "Cells" to write "Range("A:A,H:H").Select" Trip Ives[_2_] Excel Programming 3 June 5th 04 03:13 PM


All times are GMT +1. The time now is 07:00 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"