I would like to create an user-defined function in Excel that can return the current worksheet.  I could use the 
sheetname = ActiveSheet.Name
But the problem with this is, it works and suddenly it starts to get different sheet name. For example, instead of SHEET I LOVE YOU it returns SHEET I HATE YOU. 
Is there anyway to fix this - or it might possible because I think it can not be static but varies?
Right-click the ◀︎▶︎ at the left of the sheet tabs to bring up the Activate window... It provides a sequential list of the sheet names which is scrollable. Select the one you want then click the OK button.
Step 1: Type “CELL(“filename”,A1)”. The cell function is used to get the full filename and path. This function returns the filename of . xls workbook, including the sheet name.
Function MySheet()
  ' uncomment the below line to make it Volatile
  'Application.Volatile
   MySheet = Application.Caller.Worksheet.Name
End Function
This should be the function you are looking for
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With