ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Reuse Application.WorksheetFunction (https://www.excelbanter.com/excel-discussion-misc-queries/224104-reuse-application-worksheetfunction.html)

jlclyde

Reuse Application.WorksheetFunction
 
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

Gary''s Student

Reuse Application.WorksheetFunction
 
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


jlclyde

Reuse Application.WorksheetFunction
 
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

Reuse Application.WorksheetFunction
 
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

jlclyde

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


All times are GMT +1. The time now is 12:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com