Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Sumproduct in UDF

Dear All,

Excel 2000.

I cannot get the following UDF to work - it comes out as #VALUE!.

Code is entered as numbers, ex: 230
Job is entered as text, ex: Manager
Country is entered as text, ex: England
Rng1, Rng2, Rng3 and Rng4 are named ranges

Function Function_Name(Code As Integer, Job As Boolean, Country As Boolean)

Function_Name = SumProduct(--(Rng1 = Code), --(Rng2 = Job), --(Rng3 =
Country), (Rng4))

End Function

Help much appreciated.

--
Regards,

Martin
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Sumproduct in UDF

Why are you using Booleans for text strings.

This works

Function Function_Name(Code As Integer, Job As String, Country As String)
Dim sFormula As String

sFormula = "SumProduct(--(Rng1=" & Code & ")," & _
"--(Rng2=""" & Job & """)," & _
"--(Rng3=""" & Country & """), (Rng4))"
Function_Name = Evaluate(sFormula)
End Function

But why are you creating a UDF that just does what SUMPRODUCT does anyway?
Not efficient.


--
HTH

Bob Phillips

"Martin" wrote in message
...
Dear All,

Excel 2000.

I cannot get the following UDF to work - it comes out as #VALUE!.

Code is entered as numbers, ex: 230
Job is entered as text, ex: Manager
Country is entered as text, ex: England
Rng1, Rng2, Rng3 and Rng4 are named ranges

Function Function_Name(Code As Integer, Job As Boolean, Country As

Boolean)

Function_Name = SumProduct(--(Rng1 = Code), --(Rng2 = Job), --(Rng3 =
Country), (Rng4))

End Function

Help much appreciated.

--
Regards,

Martin



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Sumproduct in UDF

Hi Bob,

Thank you very much. And if I add "Application.Volatile" the UDF takes care
of any changes as well.

Using Booleans for text strings was just a silly mistake.

I am simply using UDF in this case to make an Excel application more user
friendly. There will be several different sumproduct formulas prepared. The
user will then copy these UDF formulas into other sheets within the the same
workbook. Then it's easier for the user to change cell references without
"destroying" the formula.
--
Regards,

Martin


"Bob Phillips" wrote:

Why are you using Booleans for text strings.

This works

Function Function_Name(Code As Integer, Job As String, Country As String)
Dim sFormula As String

sFormula = "SumProduct(--(Rng1=" & Code & ")," & _
"--(Rng2=""" & Job & """)," & _
"--(Rng3=""" & Country & """), (Rng4))"
Function_Name = Evaluate(sFormula)
End Function

But why are you creating a UDF that just does what SUMPRODUCT does anyway?
Not efficient.


--
HTH

Bob Phillips

"Martin" wrote in message
...
Dear All,

Excel 2000.

I cannot get the following UDF to work - it comes out as #VALUE!.

Code is entered as numbers, ex: 230
Job is entered as text, ex: Manager
Country is entered as text, ex: England
Rng1, Rng2, Rng3 and Rng4 are named ranges

Function Function_Name(Code As Integer, Job As Boolean, Country As

Boolean)

Function_Name = SumProduct(--(Rng1 = Code), --(Rng2 = Job), --(Rng3 =
Country), (Rng4))

End Function

Help much appreciated.

--
Regards,

Martin




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
Sumproduct with Condition OR Sumproduct with ADDRESS function - HE gholly Excel Discussion (Misc queries) 2 September 28th 09 05:07 PM
SUMPRODUCT Alonso[_2_] Excel Worksheet Functions 5 October 17th 08 10:29 PM
SUMPRODUCT help again Tasha Excel Discussion (Misc queries) 4 October 17th 08 06:27 PM
Conditional SUMPRODUCT or SUMPRODUCT with Filters Ted M H Excel Worksheet Functions 4 August 14th 08 07:50 PM
sumproduct? sumif(sumproduct)? David Excel Worksheet Functions 3 July 13th 07 07:06 PM


All times are GMT +1. The time now is 09:35 AM.

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

About Us

"It's about Microsoft Excel"