Search notes:

Excel: Using minus minus to convert a boolean value to 0 or 1

When involved in a mathematical expression, TRUE is considered to be 1 and FALSE to be 0.
Thus, boolean values can be turned into numerical representation by using minus (-) twice on the boolean value.
In the following example, the VBA code inserts a few boolean values into the first column and then inserts a formula with two minus signs to represent the boolean value as 0 or 1:
option explicit

sub main() ' {
 '
 '  Clear active sheet's data:
 '
    activeSheet.usedRange.clearContents

 '
 '  Fill some boolean values into the first column:
 '
    cells(1,1) = false
    cells(2,1) = true
    cells(3,1) = true
    cells(4,1) = false
    cells(5,1) = true

  '
  ' Use dash-dash (or minus minus) to turn boolean values into 0 and 1 in
  ' second column:
  '
    range(cells(1,2), cells(5, 2)).formulaR1C1 = "= -- rc[-1]"

end sub ' }
Github repository about-Excel, path: /data-types/boolean/dash-dash.bas
If run, the program produces:

See also

Using -- comes in handy for example in the sumproduct function.
Boolean data type

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Microsof...', 1758209701, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Microsoft/Office/Excel/data-types/boolean/minus-minus(73): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78