LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Create a function that sums based on two or more criteria

I am trying to create a function that sums a worksheet column based on
criteria that reside in adjacent columns. I used the following code
which gave me a type mismatch:

Function Purch_calc(look1 As String, look2 As String) As Single

Dim l1_range As Range
Dim l2_range As Range
Dim s_range As Range

With Sheet6
Set l1_range = .Range("d1:d200")
Set l2_range = .Range("b1:b200")
Set s_range = .Range("e1:e200")
End With

Purch_calc = Application.WorksheetFunction.SumProduct((l1_range =
look1) * (l2_range = look2), s_range)

End Function

Can anyone help me get the above to work or provide an alternative
method of summing a column using multiple criteria.


Thanks
Paul

 
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
create list based on criteria Bexi Excel Worksheet Functions 1 January 19th 10 08:51 PM
Create a text based count with criteria from two differnt workbook Matt Kirby Excel Worksheet Functions 4 July 30th 09 09:09 PM
How to create multiple new workbooks based on sort criteria JKR Excel Discussion (Misc queries) 7 November 4th 07 10:30 PM
How do you create COUNTIF functions based on multiple criteria? MsBeverlee Excel Worksheet Functions 8 February 19th 07 10:25 PM
Create a list based on single shared criteria David127 Excel Worksheet Functions 5 December 15th 05 02:36 AM


All times are GMT +1. The time now is 05:35 PM.

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"