Demonstration of dec2bin
The following example tries to demonstrate dec2bin
.
Unfortunately, as the second row shows,
dec2bin
cannot convert a number greater then 511, it causes a
#NUM!
cell error.
Therefore, the third row concatenates two results of dec2bin
with the concatenation operator &
.
option explicit
sub main() ' {
cells(1, 1) = 500
cells(1, 2).formulaR1C1 = "=dec2bin(rc[-1])"
cells(2, 1) = 512
cells(2, 2).formulaR1C1 = "=dec2bin(rc[-1])"
cells(3, 1) = 123456
cells(3, 2).formulaR1C1 = "=dec2bin(int(rc[-1]/512), 9) & " & _
"dec2bin(mod(rc[-1],512), 9)"
with columns(2)
.horizontalAlignment = xlRight
.select
with selection.font
.name = "Courier New"
.bold = true
end with
.autoFit
end with
cells(5, 5).select
end sub ' }