+ Reply to Thread
Results 1 to 10 of 10

SUMPRODUCT Criteria Via Cell Reference??

  1. #1
    John V
    Guest

    SUMPRODUCT Criteria Via Cell Reference??

    SUMIF allows one to enter a [valid] criteria text string into cell D2, say
    ">14000", and then reference D2 as the function criteria, e.g.,
    =SUMIF(B5:B10,D2,C5:C10).

    Is there a syntax that SUMPRODUCT will accept that does the same thing? Note
    the inclusion of a comparison operator is important.

    Thanks! JV

  2. #2
    Don Guillett
    Guest

    Re: SUMPRODUCT Criteria Via Cell Reference??

    of course,
    =sumproduct((a2:a22=d2

    --
    Don Guillett
    SalesAid Software
    [email protected]
    "John V" <[email protected]> wrote in message
    news:[email protected]...
    > SUMIF allows one to enter a [valid] criteria text string into cell D2, say
    > ">14000", and then reference D2 as the function criteria, e.g.,
    > =SUMIF(B5:B10,D2,C5:C10).
    >
    > Is there a syntax that SUMPRODUCT will accept that does the same thing?
    > Note
    > the inclusion of a comparison operator is important.
    >
    > Thanks! JV




  3. #3
    Forum Contributor EdMac's Avatar
    Join Date
    01-23-2006
    Location
    Exeter, UK
    MS-Off Ver
    2003
    Posts
    1,264
    Have a look at

    www.xldynamic.com/source/xld.SUMPRODUCT.html

    This will tell you just about all there is to know about this function

    Ed

  4. #4
    Bob Phillips
    Guest

    Re: SUMPRODUCT Criteria Via Cell Reference??

    I think he want D2 to hold the = as well Don, or say ">1400"

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "Don Guillett" <[email protected]> wrote in message
    news:[email protected]...
    > of course,
    > =sumproduct((a2:a22=d2
    >
    > --
    > Don Guillett
    > SalesAid Software
    > [email protected]
    > "John V" <[email protected]> wrote in message
    > news:[email protected]...
    > > SUMIF allows one to enter a [valid] criteria text string into cell D2,

    say
    > > ">14000", and then reference D2 as the function criteria, e.g.,
    > > =SUMIF(B5:B10,D2,C5:C10).
    > >
    > > Is there a syntax that SUMPRODUCT will accept that does the same thing?
    > > Note
    > > the inclusion of a comparison operator is important.
    > >
    > > Thanks! JV

    >
    >




  5. #5
    John V
    Guest

    Re: SUMPRODUCT Criteria Via Cell Reference??

    Thanks EdMac. I had spent a lot of time on that webpage, and you're right, it
    is excellent. However, I could find no example of where the comparison
    operator was not "hard-wired".

    I would like to use cell references so the user could specify the desired
    operator without altering the function itself. I suppose I could have a
    complicated IF statement that looked for occurences of <,>,<>,=, etc. and
    then performed the appropriate SUMPRODUCT function. But I was hoping a more
    elegant solution had been found.

    Hope this is clearer, and thanks. JV

    "EdMac" wrote:

    >
    > Have a look at
    >
    > www.xldynamic.com/source/xld.SUMPRODUCT.html
    >
    > This will tell you just about all there is to know about this function
    >
    > Ed
    >
    >
    > --
    > EdMac
    > ------------------------------------------------------------------------
    > EdMac's Profile: http://www.excelforum.com/member.php...o&userid=30736
    > View this thread: http://www.excelforum.com/showthread...hreadid=532224
    >
    >


  6. #6
    Bob Phillips
    Guest

    Re: SUMPRODUCT Criteria Via Cell Reference??

    You could always build a US+DF that will evaluate it, and use that within SP

    '---------------------------------------------------------------------
    Function fnEval(rng As Range, condition As Range) As Variant
    '---------------------------------------------------------------------
    Dim cell As Range, row As Range
    Dim i As Long, j As Long
    Dim aryValues As Variant

    If rng.Areas.Count > 1 Then
    fnEval = CVErr(xlErrValue)
    Exit Function
    End If

    If rng.Cells.Count = 1 Then
    aryValues = rng
    Else
    aryValues = rng.Value
    i = 0
    For Each row In rng.Rows
    i = i + 1: j = 0
    For Each cell In row.Cells
    j = j + 1
    aryValues(i, j) = rng.Parent.Evaluate(cell & condition)
    Next cell
    Next row
    End If

    fnEval = aryValues

    End Function

    =SUMPRODUCT(--(fnEval(B1:B10,D5))




    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "John V" <[email protected]> wrote in message
    news:[email protected]...
    > Thanks EdMac. I had spent a lot of time on that webpage, and you're right,

    it
    > is excellent. However, I could find no example of where the comparison
    > operator was not "hard-wired".
    >
    > I would like to use cell references so the user could specify the desired
    > operator without altering the function itself. I suppose I could have a
    > complicated IF statement that looked for occurences of <,>,<>,=, etc. and
    > then performed the appropriate SUMPRODUCT function. But I was hoping a

    more
    > elegant solution had been found.
    >
    > Hope this is clearer, and thanks. JV
    >
    > "EdMac" wrote:
    >
    > >
    > > Have a look at
    > >
    > > www.xldynamic.com/source/xld.SUMPRODUCT.html
    > >
    > > This will tell you just about all there is to know about this function
    > >
    > > Ed
    > >
    > >
    > > --
    > > EdMac
    > > ------------------------------------------------------------------------
    > > EdMac's Profile:

    http://www.excelforum.com/member.php...o&userid=30736
    > > View this thread:

    http://www.excelforum.com/showthread...hreadid=532224
    > >
    > >




  7. #7
    Bob Phillips
    Guest

    Re: SUMPRODUCT Criteria Via Cell Reference??

    US+DF? What's that? I meant a UDF.

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "Bob Phillips" <[email protected]> wrote in message
    news:[email protected]...
    > You could always build a US+DF that will evaluate it, and use that within

    SP
    >
    > '---------------------------------------------------------------------
    > Function fnEval(rng As Range, condition As Range) As Variant
    > '---------------------------------------------------------------------
    > Dim cell As Range, row As Range
    > Dim i As Long, j As Long
    > Dim aryValues As Variant
    >
    > If rng.Areas.Count > 1 Then
    > fnEval = CVErr(xlErrValue)
    > Exit Function
    > End If
    >
    > If rng.Cells.Count = 1 Then
    > aryValues = rng
    > Else
    > aryValues = rng.Value
    > i = 0
    > For Each row In rng.Rows
    > i = i + 1: j = 0
    > For Each cell In row.Cells
    > j = j + 1
    > aryValues(i, j) = rng.Parent.Evaluate(cell & condition)
    > Next cell
    > Next row
    > End If
    >
    > fnEval = aryValues
    >
    > End Function
    >
    > =SUMPRODUCT(--(fnEval(B1:B10,D5))
    >
    >
    >
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > (remove nothere from email address if mailing direct)
    >
    > "John V" <[email protected]> wrote in message
    > news:[email protected]...
    > > Thanks EdMac. I had spent a lot of time on that webpage, and you're

    right,
    > it
    > > is excellent. However, I could find no example of where the comparison
    > > operator was not "hard-wired".
    > >
    > > I would like to use cell references so the user could specify the

    desired
    > > operator without altering the function itself. I suppose I could have a
    > > complicated IF statement that looked for occurences of <,>,<>,=, etc.

    and
    > > then performed the appropriate SUMPRODUCT function. But I was hoping a

    > more
    > > elegant solution had been found.
    > >
    > > Hope this is clearer, and thanks. JV
    > >
    > > "EdMac" wrote:
    > >
    > > >
    > > > Have a look at
    > > >
    > > > www.xldynamic.com/source/xld.SUMPRODUCT.html
    > > >
    > > > This will tell you just about all there is to know about this function
    > > >
    > > > Ed
    > > >
    > > >
    > > > --
    > > > EdMac

    > >

    > ------------------------------------------------------------------------
    > > > EdMac's Profile:

    > http://www.excelforum.com/member.php...o&userid=30736
    > > > View this thread:

    > http://www.excelforum.com/showthread...hreadid=532224
    > > >
    > > >

    >
    >




  8. #8
    John V
    Guest

    Re: SUMPRODUCT Criteria Via Cell Reference??

    Heh Heh. I was too wimpy to ask, then eventually pieced it together. Thanks
    for your help. Also, I enjoy reading what is, to my eye, elegant code. Wish I
    had more of your skill set.

    "Bob Phillips" wrote:

    > US+DF? What's that? I meant a UDF.
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > (remove nothere from email address if mailing direct)
    >
    > "Bob Phillips" <[email protected]> wrote in message
    > news:[email protected]...
    > > You could always build a US+DF that will evaluate it, and use that within

    > SP
    > >
    > > '---------------------------------------------------------------------
    > > Function fnEval(rng As Range, condition As Range) As Variant
    > > '---------------------------------------------------------------------
    > > Dim cell As Range, row As Range
    > > Dim i As Long, j As Long
    > > Dim aryValues As Variant
    > >
    > > If rng.Areas.Count > 1 Then
    > > fnEval = CVErr(xlErrValue)
    > > Exit Function
    > > End If
    > >
    > > If rng.Cells.Count = 1 Then
    > > aryValues = rng
    > > Else
    > > aryValues = rng.Value
    > > i = 0
    > > For Each row In rng.Rows
    > > i = i + 1: j = 0
    > > For Each cell In row.Cells
    > > j = j + 1
    > > aryValues(i, j) = rng.Parent.Evaluate(cell & condition)
    > > Next cell
    > > Next row
    > > End If
    > >
    > > fnEval = aryValues
    > >
    > > End Function
    > >
    > > =SUMPRODUCT(--(fnEval(B1:B10,D5))
    > >
    > >
    > >
    > >
    > > --
    > > HTH
    > >
    > > Bob Phillips
    > >
    > > (remove nothere from email address if mailing direct)
    > >
    > > "John V" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > Thanks EdMac. I had spent a lot of time on that webpage, and you're

    > right,
    > > it
    > > > is excellent. However, I could find no example of where the comparison
    > > > operator was not "hard-wired".
    > > >
    > > > I would like to use cell references so the user could specify the

    > desired
    > > > operator without altering the function itself. I suppose I could have a
    > > > complicated IF statement that looked for occurences of <,>,<>,=, etc.

    > and
    > > > then performed the appropriate SUMPRODUCT function. But I was hoping a

    > > more
    > > > elegant solution had been found.
    > > >
    > > > Hope this is clearer, and thanks. JV
    > > >
    > > > "EdMac" wrote:
    > > >
    > > > >
    > > > > Have a look at
    > > > >
    > > > > www.xldynamic.com/source/xld.SUMPRODUCT.html
    > > > >
    > > > > This will tell you just about all there is to know about this function
    > > > >
    > > > > Ed
    > > > >
    > > > >
    > > > > --
    > > > > EdMac
    > > >

    > > ------------------------------------------------------------------------
    > > > > EdMac's Profile:

    > > http://www.excelforum.com/member.php...o&userid=30736
    > > > > View this thread:

    > > http://www.excelforum.com/showthread...hreadid=532224
    > > > >
    > > > >

    > >
    > >

    >
    >
    >


  9. #9
    Bob Phillips
    Guest

    Re: SUMPRODUCT Criteria Via Cell Reference??

    I think I'll add it to the web page.

    --
    HTH

    Bob Phillips

    (remove nothere from email address if mailing direct)

    "John V" <[email protected]> wrote in message
    news:[email protected]...
    > Heh Heh. I was too wimpy to ask, then eventually pieced it together.

    Thanks
    > for your help. Also, I enjoy reading what is, to my eye, elegant code.

    Wish I
    > had more of your skill set.
    >
    > "Bob Phillips" wrote:
    >
    > > US+DF? What's that? I meant a UDF.
    > >
    > > --
    > > HTH
    > >
    > > Bob Phillips
    > >
    > > (remove nothere from email address if mailing direct)
    > >
    > > "Bob Phillips" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > You could always build a US+DF that will evaluate it, and use that

    within
    > > SP
    > > >
    > > > '---------------------------------------------------------------------
    > > > Function fnEval(rng As Range, condition As Range) As Variant
    > > > '---------------------------------------------------------------------
    > > > Dim cell As Range, row As Range
    > > > Dim i As Long, j As Long
    > > > Dim aryValues As Variant
    > > >
    > > > If rng.Areas.Count > 1 Then
    > > > fnEval = CVErr(xlErrValue)
    > > > Exit Function
    > > > End If
    > > >
    > > > If rng.Cells.Count = 1 Then
    > > > aryValues = rng
    > > > Else
    > > > aryValues = rng.Value
    > > > i = 0
    > > > For Each row In rng.Rows
    > > > i = i + 1: j = 0
    > > > For Each cell In row.Cells
    > > > j = j + 1
    > > > aryValues(i, j) = rng.Parent.Evaluate(cell &

    condition)
    > > > Next cell
    > > > Next row
    > > > End If
    > > >
    > > > fnEval = aryValues
    > > >
    > > > End Function
    > > >
    > > > =SUMPRODUCT(--(fnEval(B1:B10,D5))
    > > >
    > > >
    > > >
    > > >
    > > > --
    > > > HTH
    > > >
    > > > Bob Phillips
    > > >
    > > > (remove nothere from email address if mailing direct)
    > > >
    > > > "John V" <[email protected]> wrote in message
    > > > news:[email protected]...
    > > > > Thanks EdMac. I had spent a lot of time on that webpage, and you're

    > > right,
    > > > it
    > > > > is excellent. However, I could find no example of where the

    comparison
    > > > > operator was not "hard-wired".
    > > > >
    > > > > I would like to use cell references so the user could specify the

    > > desired
    > > > > operator without altering the function itself. I suppose I could

    have a
    > > > > complicated IF statement that looked for occurences of <,>,<>,=,

    etc.
    > > and
    > > > > then performed the appropriate SUMPRODUCT function. But I was hoping

    a
    > > > more
    > > > > elegant solution had been found.
    > > > >
    > > > > Hope this is clearer, and thanks. JV
    > > > >
    > > > > "EdMac" wrote:
    > > > >
    > > > > >
    > > > > > Have a look at
    > > > > >
    > > > > > www.xldynamic.com/source/xld.SUMPRODUCT.html
    > > > > >
    > > > > > This will tell you just about all there is to know about this

    function
    > > > > >
    > > > > > Ed
    > > > > >
    > > > > >
    > > > > > --
    > > > > > EdMac
    > > > >

    > >

    > ------------------------------------------------------------------------
    > > > > > EdMac's Profile:
    > > > http://www.excelforum.com/member.php...o&userid=30736
    > > > > > View this thread:
    > > > http://www.excelforum.com/showthread...hreadid=532224
    > > > > >
    > > > > >
    > > >
    > > >

    > >
    > >
    > >




  10. #10
    Registered User
    Join Date
    07-10-2014
    Location
    india
    MS-Off Ver
    2010
    Posts
    1

    Re: SUMPRODUCT Criteria Via Cell Reference??

    Bob,

    Your help is greatly apprecited.

    Thanks very much for this UDF...This really helped many days of my effort.

    This UDF is working for Named ranges if they are numbers only, but I do have named ranges with text content.

    Could you please help me to update this function to take care of text named ranges also.

    Thanks again,
    Murali

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1