Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default User Defined Function - Using Cell Range

Hello,
I have a question about creating a user defined function...

I want it to make some calculations based off of static cell ranges. I was
hoping I could use either a named range, or just type in a static range in
the function.

Like, how would I do WorksheetFunction.SUM(RANGE) in a UDF?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default User Defined Function - Using Cell Range

Function SumRange(rng As Range) As Double

SumRange = Application.WorksheetFunction.Sum(rng)

End Function


Sub test()

MsgBox SumRange(Range(Cells(1), Cells(3, 2)))

End Sub


RBS

"I need help please" wrote in
message ...
Hello,
I have a question about creating a user defined function...

I want it to make some calculations based off of static cell ranges. I
was
hoping I could use either a named range, or just type in a static range in
the function.

Like, how would I do WorksheetFunction.SUM(RANGE) in a UDF?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default User Defined Function - Using Cell Range

something like this will give the sum of A1:A10 in Sheet1

Dim dblSum As Double
dblSum = WorksheetFunction.Sum(Sheets("Sheet1").Range("A1:A 10"))

to use a named range, you can do it this way

dblSum = WorksheetFunction.Sum(Range("NamedRange"))



--
Hope that helps.

Vergel Adriano


"I need help please" wrote:

Hello,
I have a question about creating a user defined function...

I want it to make some calculations based off of static cell ranges. I was
hoping I could use either a named range, or just type in a static range in
the function.

Like, how would I do WorksheetFunction.SUM(RANGE) in a UDF?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default User Defined Function - Using Cell Range

Thanks - the Sheets("Sheet1").Range("A1:A10") did the trick!!

"Vergel Adriano" wrote:

something like this will give the sum of A1:A10 in Sheet1

Dim dblSum As Double
dblSum = WorksheetFunction.Sum(Sheets("Sheet1").Range("A1:A 10"))

to use a named range, you can do it this way

dblSum = WorksheetFunction.Sum(Range("NamedRange"))



--
Hope that helps.

Vergel Adriano


"I need help please" wrote:

Hello,
I have a question about creating a user defined function...

I want it to make some calculations based off of static cell ranges. I was
hoping I could use either a named range, or just type in a static range in
the function.

Like, how would I do WorksheetFunction.SUM(RANGE) in a UDF?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing a range to a user defined function Gary Nelson Excel Discussion (Misc queries) 1 July 19th 07 04:22 PM
user defined function receiving a range as parameter Marc Excel Programming 7 October 14th 05 07:50 PM
Passing a named range into a user defined function Simon Shaw Excel Programming 2 March 15th 05 09:33 PM
passing named range to a UDF user defined function Brian Murphy Excel Programming 3 June 13th 04 08:38 PM
passing a range to a user defined function using a form davek Excel Programming 1 December 24th 03 07:40 AM


All times are GMT +1. The time now is 06:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"