Closed Thread
Results 1 to 3 of 3

-- in SUMPRODUCT function?

Hybrid View

  1. #1
    Registered User
    Join Date
    11-20-2007
    Location
    Vancouver, Canada
    MS-Off Ver
    2013
    Posts
    2

    Exclamation -- in SUMPRODUCT function?

    Hi everyone - first post

    In the following function, what do the -- mean?

    =SUMPRODUCT(--(E7:E52="Yes"),--(I7:I52=1))

    Thanks in advance

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    -- in SUMPRODUCT function?

    That is called a "double unary". Here's why and how it's used:

    Excel does not automatically consider boolean values (TRUE/FALSE) to be numbers. You need to coerce them into becoming numbers.

    That is done by applying an arithmetic operator (+,-,*,/) to them.
    Then Excel converts TRUE to 1, FALSE to 0.

    For example:
    If A1:=TRUE

    B1: =ISNUMBER(A1)
    returns FALSE because Excel doesn't recognize TRUE as a numeric value.

    But all of these return 1:
    B1: =ISNUMBER(A1+0)
    B1: =ISNUMBER(A1/1)
    B1: =ISNUMBER(A1*1)
    B1: =ISNUMBER(--A1)

    However, the first 3 of those formulas might be confused as an attempt to do a calculation.

    Consequently, experienced Excel users understand that a Double-Unary (--)
    indicates that we are forcing a conversion, not peforming a calculation.

    It works this way:
    -TRUE becomes -1
    --TRUE becomes 1 (because the negative of a negative number is a positive number)

    Does that help?
    Last edited by Ron Coderre; 11-20-2007 at 11:15 PM.
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    11-20-2007
    Location
    Vancouver, Canada
    MS-Off Ver
    2013
    Posts
    2
    not really - I think its a little too technical for me.

    Thanks though

Closed 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