View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
michael.beckinsale michael.beckinsale is offline
external usenet poster
 
Posts: 274
Default Excel 2007 and macros/functions

On Jul 8, 9:52*am, jodleren wrote:
Hello

I have a small function, so I can get the name of the present sheet...

It goes:
Function GetSheetName() As String
'ByVal Sheet As Worksheet
* GetSheetName = ActiveSheet.Name
End Function

and as formula it is used:
=GetSheetName();

however, that does not work in excel 2007
why?

WBR
Sonnich


jodleren

Amend as below so that the function responds to changes:

Function GetSheetName() As String
Application.Volatile
GetSheetName = ActiveSheet.Name
End Function

Another way is as follows:

Function GetSheetName As String
Application.Volatile
GetSheetName = Application.Caller.Parent.Name
End Function

Both the above tested with XL2003 & XL2007

Regards

Michael Beckinsale