Function trimformula(targetCell As Range)
Dim X As String
Dim Y As String
Dim A As Integer
Dim B As Variant
X = InStr(1, targetCell.FormulaLocal, "(", vbTextCompare)
Y = InStr(1, targetCell.FormulaLocal, "!", vbTextCompare)
A = (Y - X)
B = Mid(targetCell.FormulaLocal, X + 1, A - 1)
trimformula = B
End Function
HI,
In Cell D1 I have a formula =AAA!A1
AAA is a Sheet Name of another sheet
Am I out of date here or from what I understand =AAA!A1 is not Excel conventional sheet naming within a formula nor is it a formula?
Anyway you can edit the Function above just replace the "(" with an "=".
you will need to use this formula in the same sheet whose name you want to extract
=MID(CELL("filename"),SEARCH("]",CELL("filename"),1)+1,LEN(CELL("filename")))