Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Code names for excel sheets

Hi,

I am using the code names method to reference sheets from a Macro,
this works great when I have only one workbook open.

But, I would like to copy all the sheets into a new workbook, do some
stuff with the data in the new workbook (my problem is here!), save
the new workbook and then return to the original workbook.

Once I have copied all the sheets into a new workbook (so there code
names are identical) I try to used the following code which does not
work:

Windows(NewWindowName).Activate
Summary.Select
Call myMethod

Note: NewWindowName is the filename of the new workbook; and Summary
is the codename for one of the sheets in both the old and new
workbook.

I would rather use the codenames so that the method is dynamic.

Please does anybody know how to fix this??

I have tried things like Activeworkbook.Summary.Select with no
success....

Thanks in advance for your time.

A
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,420
Default Code names for excel sheets

Windows(NewWindowName).Activate
With wb.VBProject

.VBComponents(.VBComponents("Summary").Properties( "Codename")).Properties("Name").Select
End With
Call myMethod


--
__________________________________
HTH

Bob

"alan82" wrote in message
...
Hi,

I am using the code names method to reference sheets from a Macro,
this works great when I have only one workbook open.

But, I would like to copy all the sheets into a new workbook, do some
stuff with the data in the new workbook (my problem is here!), save
the new workbook and then return to the original workbook.

Once I have copied all the sheets into a new workbook (so there code
names are identical) I try to used the following code which does not
work:

Windows(NewWindowName).Activate
Summary.Select
Call myMethod

Note: NewWindowName is the filename of the new workbook; and Summary
is the codename for one of the sheets in both the old and new
workbook.

I would rather use the codenames so that the method is dynamic.

Please does anybody know how to fix this??

I have tried things like Activeworkbook.Summary.Select with no
success....

Thanks in advance for your time.

A



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,420
Default Code names for excel sheets

wb refers to the activeworkbook here BTW

--
__________________________________
HTH

Bob

"Bob Phillips" wrote in message
...
Windows(NewWindowName).Activate
With wb.VBProject


.VBComponents(.VBComponents("Summary").Properties( "Codename")).Properties("Name").Select
End With
Call myMethod


--
__________________________________
HTH

Bob

"alan82" wrote in message
...
Hi,

I am using the code names method to reference sheets from a Macro,
this works great when I have only one workbook open.

But, I would like to copy all the sheets into a new workbook, do some
stuff with the data in the new workbook (my problem is here!), save
the new workbook and then return to the original workbook.

Once I have copied all the sheets into a new workbook (so there code
names are identical) I try to used the following code which does not
work:

Windows(NewWindowName).Activate
Summary.Select
Call myMethod

Note: NewWindowName is the filename of the new workbook; and Summary
is the codename for one of the sheets in both the old and new
workbook.

I would rather use the codenames so that the method is dynamic.

Please does anybody know how to fix this??

I have tried things like Activeworkbook.Summary.Select with no
success....

Thanks in advance for your time.

A





  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Code names for excel sheets

Apologies, I have not explained my problem clearly....

This method still requires that I make some static reference to the
sheet name.

I can just use:

Sheets("Summary").select

instead. The reason that i want to use the code name is because I have
other sheets that show information corresponding to a date. The sheet
name will change according to date, but the code name will not. e.g. I
have the following codenames for sheets.

Summary
Yr1
Yr2
Yr2

The actual name that is displayed on the tab in excel will vary for
sheets Yr1, Yr2, Yr3. Hence I would like to avoid making a static
reference to the name... my code will not be dynamic in this case.

Can I retrieve the codename for a sheet without using the name that is
displayed on the sheets tab?


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,420
Default Code names for excel sheets

No, Summary is the codename in this example. You cannot reference a sheet in
another workbook by its code name so I gave you code to retrieve the Excel
sheet name from the code name, and then use that.

--
__________________________________
HTH

Bob

"alan82" wrote in message
...
Apologies, I have not explained my problem clearly....

This method still requires that I make some static reference to the
sheet name.

I can just use:

Sheets("Summary").select

instead. The reason that i want to use the code name is because I have
other sheets that show information corresponding to a date. The sheet
name will change according to date, but the code name will not. e.g. I
have the following codenames for sheets.

Summary
Yr1
Yr2
Yr2

The actual name that is displayed on the tab in excel will vary for
sheets Yr1, Yr2, Yr3. Hence I would like to avoid making a static
reference to the name... my code will not be dynamic in this case.

Can I retrieve the codename for a sheet without using the name that is
displayed on the sheets tab?






  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Code names for excel sheets

ok, this is clear now.

thanks for your help!
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
Transferring Names between excel sheets John Excel Discussion (Misc queries) 2 June 19th 08 01:01 PM
Getting & Using Sheet Names or Index in VBA code rwjack New Users to Excel 4 April 14th 08 01:50 PM
Sheet names code Jonah Excel Discussion (Misc queries) 8 November 4th 06 03:03 AM
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Excel Worksheet Functions 6 March 29th 06 12:43 PM
how do i get the names of the sheets Reny J Joseph Thuthikattu Excel Worksheet Functions 1 December 11th 04 09:37 AM


All times are GMT +1. The time now is 07:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"