IN VBA
Function SNAME(number As String) As String
Dim WORD$
WORD = "Sheet" + number
' SNAME = Worksheets(1).CodeName
For i = 1 To ThisWorkbook.Worksheets.Count
If Worksheets(i).CodeName = WORD Then SNAME = Worksheets(i).Name
Next i
End Function
IN EXCEL
=SUMIFS((SNAME(19)!$T$2:$T$9962),(SNAME(19)!$A$2:$A$9962),"=31",(SNAME(19)!$C$2:$C$9962),"<="&EDATE(TODAY(),-12))
Purpose:
The idea here is that I want to pass the sheets name to the range function based on its code name. the VBA function SNAME seems functional and returns the worksheet's name based on the VBA object code name. When I try to combine that with the range function in the equation, there seems to be an error I'm unsure how to resolve. When I replace SNAME(19) with the sheet name the Equation executes properly.
Goal:
I need to be able to reference the sheet using its code name to avoid future errors of individuals changing the name of the sheets. I'd really appreciate any advice someone might have on the issue.