View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
jodleren jodleren is offline
external usenet poster
 
Posts: 49
Default Excel 2007 and macros/functions

On Jul 8, 9:23*pm, Chip Pearson wrote:
GetSheetName = ActiveSheet.Name


That is probably not what you want. With that code, the function will
return the name of whatever sheet happens to be active when Excel
decides it is time to calculate. There is no certainty that
ActiveSheet will be the same as the sheet on which the formula
resides. This can cause problems that may be hard to diagnose.

Instead, use Application.Caller, which, when called from a worksheet
cell, will return a Range reference to the cell whence the function
was called.

Function GetSheetName() As String
* * GetSheetName = Application.Caller.Worksheet.Name
End Function


Well, the result is the same: #NAME? Error.

When I search for help on the error it tries to download something,
but fails.

BTW, the same problem aplies to Visual Studio 2008, all help requests
are replied by "information not found".

/S