Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Changing VB Component Names to match Worksheet names using VBE

Hi,

In VBE the worksheets can be identified using a name that never changes
(default Sheet1 etc)

To retrieve that name I can do this:
VBProject.VBComponents(index).name

and I can change it in a similar way.

My problem is this... I am building new by copying entire sheets (which have
lots of data) into a new template - that has a new VB Project.

I want to rename the VB Code Module of each copied worksheet from it's
current default (like Sheet1) to the name it has in the workbook in Excel...

so how, using the VBIDE/VBE Object module can I reference the code module of
a worksheet to change it's name to the name it has in the workbook?

thanks

Philip
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 156
Default Changing VB Component Names to match Worksheet names using VBE

I got it... simplicity itself:

For Each objSheet In Worksheets
objSheet.CodeName = VBA.Replace(objSheet.Name, " ", "_")
Next

thx anyway

"Philip" wrote:

Hi,

In VBE the worksheets can be identified using a name that never changes
(default Sheet1 etc)

To retrieve that name I can do this:
VBProject.VBComponents(index).name

and I can change it in a similar way.

My problem is this... I am building new by copying entire sheets (which have
lots of data) into a new template - that has a new VB Project.

I want to rename the VB Code Module of each copied worksheet from it's
current default (like Sheet1) to the name it has in the workbook in Excel...

so how, using the VBIDE/VBE Object module can I reference the code module of
a worksheet to change it's name to the name it has in the workbook?

thanks

Philip

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
using the Excel generic worksheet names instead of user-given names in code Paul Excel Discussion (Misc queries) 5 June 26th 09 08:44 PM
can worksheet names be changed by changing certain cells? anand Excel Worksheet Functions 4 October 5th 07 02:27 PM
Changing worksheet names Carolyn Excel Worksheet Functions 1 November 10th 06 05:21 AM
return all worksheet tab names and chart sheet tab names in report - an example DataFreakFromUtah Excel Programming 2 October 6th 04 08:09 PM
Change names of files in a folder to match names in Excel Column saybut Excel Programming 4 February 9th 04 06:26 PM


All times are GMT +1. The time now is 05:51 PM.

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"