Thread: Excel function
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
berimbao78 berimbao78 is offline
external usenet poster
 
Posts: 5
Default Excel function

Thanks !!
Here's the code I finally used:
Sub Ajoute()

Dim CategName As String
CategName = "MyCateg"

Sheets.Add Type:=xlExcel4MacroSheet
ActiveWorkbook.Names.Add Name:="TmpFunction",
RefersToR1C1:="=Macro1!R1C1", _
Category:="MyCateg", MacroType:=xlFunction

AjouteFonction ("MyFunc")
AjouteFonction ("MyOtherFunc")

Application.DisplayAlerts = False
ActiveWindow.SelectedSheets.Delete
Application.DisplayAlerts = True
End Sub

Sub AjouteFonction(funcName As String)
On Error GoTo err:
For i = 1 To 20
Application.MacroOptions Macro:=funcName, Category:=i
Next i
err:
End Sub
Public Function MyFunc(dbl1 As Double, dbl2 As Double) As Double
MyFunc = dbl1 + dbl2
End Function
Public Function MyOtherFunc(dbl1 As Double, dbl2 As Double) As Double
MyFunc = dbl1 * dbl2
End Function