Reuse Application.WorksheetFunction
On Mar 12, 2:52*pm, Dave Peterson wrote:
Dim Fn As WorksheetFunction
Set Fn = Application.WorksheetFunction
MsgBox Fn.Sum(Range("A:a"))
jlclyde wrote:
On Mar 12, 2:24 pm, Gary''s Student
wrote:
Use your own UDF:
Function zum(r As Range) As Variant
zum = Application.WorksheetFunction.Sum(r)
End Function
Sub main()
Dim r As Range
Set r = Range("A1:A10")
x = zum(r)
MsgBox (x)
End Sub
once you have defined zum(), you can re-use it over and over.
--
Gary''s Student - gsnu2007L
"jlclyde" wrote:
Is there a way to reuse the Application.WorksheetFunction?
For instance there are several times in the macro that I am writting
that I would like to do Application.worksheetfunction.SUM(XXXXX). *It
woudl be nice if I could do Fn.Sum(XXXXX) or Fn.SUMIF(XXXXXXX)
Thanks,
Jay- Hide quoted text -
- Show quoted text -
I need to change the function often. *I am lookign for a way to reuse
the Application.WorksheetFunction section. *Or turn it into Fn, so
that I only have to type Fn.Sum(XXX) *or Fn.CountA(XXXX).
Thanks,
Jay
--
Dave Peterson- Hide quoted text -
- Show quoted text -
Thanks this works exactly like I had hoped it would.
Jay
|