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