I am trying to write a function that takes a cell's value, for example A1 = Sheet1, which is the codename of Sheet1, and return the worksheet name (which appears on the tab).
So in Microsoft Excel Objects you have Sheet1 (HelloWorld)
In cell A1 is the value Sheet1
In cell A2 I to write a function =GetSheetName(A1) and it returns the value HelloWorld.
I was able to do this in the reverse order (get Sheet1 from HelloWorld) with:
Public Function GetSheetName(rCell As String)
GetSheetName = rCell
GetSheetName = Worksheets(rCell).CodeName
End Function
But this does not work the other way around.
Thanks
So in Microsoft Excel Objects you have Sheet1 (HelloWorld)
In cell A1 is the value Sheet1
In cell A2 I to write a function =GetSheetName(A1) and it returns the value HelloWorld.
I was able to do this in the reverse order (get Sheet1 from HelloWorld) with:
Public Function GetSheetName(rCell As String)
GetSheetName = rCell
GetSheetName = Worksheets(rCell).CodeName
End Function
But this does not work the other way around.
Thanks
Last edited: