Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Changing Codename in VBA

2003


If I run this code is the respective w/s ThisWorkbook code window it
works fine.

ThisWorkbook.VBProject.VBComponents(wks.CodeName). Name = "Sheet2"

But if I run the code from another module I get an error 9 Subscript
not found or out of range. I did activate the worksheet in VBA prior
to running the code.

That said, I would like to change a Copied w/s Codename because it kept
the same Codename in the previous file. I would like to change the
Codename to "Sheet2" with VBA from another module.
Is this possible?

TIA EagleOne

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Changing Codename in VBA

Your code works fine for me as long as it is called from any module within
the same VBProject. If you call it from Workbook2 and Wks refers to a
worksheet in Workbook1, the code will fail.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"Dennis" wrote in message
ups.com...
2003


If I run this code is the respective w/s ThisWorkbook code window it
works fine.

ThisWorkbook.VBProject.VBComponents(wks.CodeName). Name = "Sheet2"

But if I run the code from another module I get an error 9 Subscript
not found or out of range. I did activate the worksheet in VBA prior
to running the code.

That said, I would like to change a Copied w/s Codename because it kept
the same Codename in the previous file. I would like to change the
Codename to "Sheet2" with VBA from another module.
Is this possible?

TIA EagleOne



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Changing Codename in VBA


Actually, I am calling from my Personal.xls but your point is still
valid.
I am still trying to conceive a workaround.

Thanks Chip.

Chip Pearson wrote:
Your code works fine for me as long as it is called from any module within
the same VBProject. If you call it from Workbook2 and Wks refers to a
worksheet in Workbook1, the code will fail.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"Dennis" wrote in message
ups.com...
2003


If I run this code is the respective w/s ThisWorkbook code window it
works fine.

ThisWorkbook.VBProject.VBComponents(wks.CodeName). Name = "Sheet2"

But if I run the code from another module I get an error 9 Subscript
not found or out of range. I did activate the worksheet in VBA prior
to running the code.

That said, I would like to change a Copied w/s Codename because it kept
the same Codename in the previous file. I would like to change the
Codename to "Sheet2" with VBA from another module.
Is this possible?

TIA EagleOne


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Changing Codename in VBA


Actually, I am calling from my Personal.xls but your point is still
valid.
I am still trying to conceive a workaround.

Thanks Chip.

Chip Pearson wrote:
Your code works fine for me as long as it is called from any module within
the same VBProject. If you call it from Workbook2 and Wks refers to a
worksheet in Workbook1, the code will fail.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"Dennis" wrote in message
ups.com...
2003


If I run this code is the respective w/s ThisWorkbook code window it
works fine.

ThisWorkbook.VBProject.VBComponents(wks.CodeName). Name = "Sheet2"

But if I run the code from another module I get an error 9 Subscript
not found or out of range. I did activate the worksheet in VBA prior
to running the code.

That said, I would like to change a Copied w/s Codename because it kept
the same Codename in the previous file. I would like to change the
Codename to "Sheet2" with VBA from another module.
Is this possible?

TIA EagleOne


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
string to codename rk0909 Excel Discussion (Misc queries) 4 September 25th 08 10:57 PM
VBA codename and codeprotection CoCo Excel Programming 0 August 10th 06 04:46 AM
codename help Gary Keramidas Excel Programming 14 October 31st 05 12:32 AM
Worksheet codename Andy Excel Programming 4 December 2nd 03 04:12 PM


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