MrRhodes2004
12-03-2016, 12:50 PM
Hey Y'all,
I'm struggling with passing a worksheet codename through the a subroutine. Below is an example of what I have been trying to do. The intent is to have a single function that works on the called sheet.
I'd like to be able to send the sheet codename instead of the name itself as that might get changed.
When I pass the name, the function seems to work properly. However, when I try to use the codename....nope.
Sub tryPassSheetName(wName$)
Dim ws As Worksheet
Set ws = ActiveWorkbook.Sheets(wName)
Debug.Print ws.CodeName
End Sub
Sub testy()
tryPassSheetName ("Sheet29") 'codename of the sheet (Does NOT work)
tryPassSheetName ("TL List of Indicators") 'actual name of the sheet (Works only until user changes sheet name)
End Sub
Thoughts?
I'm struggling with passing a worksheet codename through the a subroutine. Below is an example of what I have been trying to do. The intent is to have a single function that works on the called sheet.
I'd like to be able to send the sheet codename instead of the name itself as that might get changed.
When I pass the name, the function seems to work properly. However, when I try to use the codename....nope.
Sub tryPassSheetName(wName$)
Dim ws As Worksheet
Set ws = ActiveWorkbook.Sheets(wName)
Debug.Print ws.CodeName
End Sub
Sub testy()
tryPassSheetName ("Sheet29") 'codename of the sheet (Does NOT work)
tryPassSheetName ("TL List of Indicators") 'actual name of the sheet (Works only until user changes sheet name)
End Sub
Thoughts?