Referencing a sheet using the sheet name

orion_wa

New Member
Joined
Jun 26, 2008
Messages
2
a quick problem. im not too sure how to do this
anyways.. i'll give you a quick example of what im trying to do.

okay i want to make some quick formulas but i dont want to use the sheet name like it normally does. and i need to make it function while cells are protected so it cant be a vb script. okay for short.

you have a sheet name.. then you have its actual name.
one is visible.. and the other is only visible when you go into properties.

anyways the visible sheet name needs to be loose as it will potentially change with some of my other scripts. so when i reference a cell in vb i use the actual sheet name instead of the visible name.
now all i need to know is how i can reference the actual name in a excell script.. like for example
with the visible name i would call something from the sheet using somethin like

=sheet1!C1R1

does anyone know how i can do it using the properties name ?

any help would be helpful
ta
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
I think you are talking about the .CodeName vs. the .Name properties.

Code:
Sheets("NameOnTab")
uses the .Name property of a sheet to refer to it.

This function
Code:
Function SheetFromCodeName(codeNameString As String) As  Worksheet 
    On  Error Resume Next 
    With  ThisWorkbook.VBProject.vbcomponents(codeNameString) 
        Set SheetFromCodeName = ThisWorkbook.Sheets(. properties("index").Value) 
    End With 
    On Error Goto 0 
End Function
will return the sheet when given its code name.
 
Last edited:
Upvote 0
umm.. your confusing me.. i dont want to get the name.

i want to do an excel script using the properties codename rather then tab name.

so in a cell i want to make a forumula referencing the sheet using the codename rather then the sheet tabname
does that make more sence ?
 
Upvote 0
Let me add another UDF.

Code:
Function TabNameFromCodeName(codeNameString as String) as String
    tabNameFromCodeName = SheetFromCodeName(codeNameString).Name
End Function

Putting both UDF's in a module will permit spreadsheet functions like

=SUM(INDIRECT(TabNameFromCodeName("codeName") & "!A1:A10"))
 
Upvote 0

Forum statistics

Threads
1,214,926
Messages
6,122,306
Members
449,079
Latest member
juggernaut24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top