A formula like:
=RIGHT(CELL("filename",A1),
LEN(CELL("filename",A1))-FIND("]",CELL("filename",A1)))
will return the name of the worksheet (if the workbook has been saved).
You can use that long formula in an if statement--or put that formula in a cell,
then use a reference to that cell in your formula.