#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 50
Default string to codename

All,

I am creating a template model. I would codename (NOT SHEET NAME) 15
different sheets as Entity1, Entity2,.......Entity15.

Is there a way I can convert a string into a codename. e.g.

Dim MySheet as Worksheet, n as integer

for n = 1 to 15
MySheet = "Entity" & n
MySheet.activate
run Code
next

This code does not work???

Any help appreciated.

RK

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default string to codename

Try this. Also can name at the same time. NO selections necessary

Sub ChangeCodeNameandSheetName()
For i = 1 To Sheets.Count
ThisWorkbook.VBProject.VBComponents(Sheets(i).Code Name) _
.Properties("_CodeName").Value = "Entity" & i
Sheets(i).Name = "RK" & i
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"rk0909" wrote in message
...
All,

I am creating a template model. I would codename (NOT SHEET NAME) 15
different sheets as Entity1, Entity2,.......Entity15.

Is there a way I can convert a string into a codename. e.g.

Dim MySheet as Worksheet, n as integer

for n = 1 to 15
MySheet = "Entity" & n
MySheet.activate
run Code
next

This code does not work???

Any help appreciated.

RK


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default string to codename

Try this...

Dim MySheet as Worksheet, n as long

for n = 1 to 15
with thisworkbook
Set MySheet = .Worksheets(.VBProject.VBComponents("Entity" &
n).Properties("Name").Value)
end with
MySheet.activate
run Code
next n
--
HTH...

Jim Thomlinson


"rk0909" wrote:

All,

I am creating a template model. I would codename (NOT SHEET NAME) 15
different sheets as Entity1, Entity2,.......Entity15.

Is there a way I can convert a string into a codename. e.g.

Dim MySheet as Worksheet, n as integer

for n = 1 to 15
MySheet = "Entity" & n
MySheet.activate
run Code
next

This code does not work???

Any help appreciated.

RK

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 50
Default string to codename

Jim,

This is exactly what I was looking for.

Thanks much,

RK

"Jim Thomlinson" wrote:

Try this...

Dim MySheet as Worksheet, n as long

for n = 1 to 15
with thisworkbook
Set MySheet = .Worksheets(.VBProject.VBComponents("Entity" &
n).Properties("Name").Value)
end with
MySheet.activate
run Code
next n
--
HTH...

Jim Thomlinson


"rk0909" wrote:

All,

I am creating a template model. I would codename (NOT SHEET NAME) 15
different sheets as Entity1, Entity2,.......Entity15.

Is there a way I can convert a string into a codename. e.g.

Dim MySheet as Worksheet, n as integer

for n = 1 to 15
MySheet = "Entity" & n
MySheet.activate
run Code
next

This code does not work???

Any help appreciated.

RK

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
Change 3 letter text string to a number string Pete Excel Discussion (Misc queries) 3 December 31st 07 07:47 PM
counting the number of instances of a string within another string Keith R Excel Worksheet Functions 3 March 5th 07 06:54 PM
Splitting a text string into string and number mcambrose Excel Discussion (Misc queries) 4 February 21st 06 03:47 PM
to search for a string and affect data if it finds the string? Shwaman Excel Worksheet Functions 1 January 11th 06 12:56 AM
Referencing worksheet CODENAME in a chart object. Bing Excel Discussion (Misc queries) 1 February 15th 05 01:01 AM


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