string to codename

  • Thread starter Thread starter rk0909
  • Start date Start date
R

rk0909

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
 
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).CodeName) _
.Properties("_CodeName").Value = "Entity" & i
Sheets(i).Name = "RK" & i
Next i
End Sub
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

VBA:: determine if UDF exists? 1
[Q] How to sort tabs in order of CodeName 2
Macro range 2
Codename not set 3
Macro copy from range 3
macro to hide sheets 5
Efficient use of sheet "codenames" 5
Codename passing 3

Back
Top