2

According to the relevant Microsoft Support page on the BITAND function, I should have access to it, as I am running Excel for Mac 2011 (with the latest updates installed):

"APPLIES TO: Excel 2016, Excel 2013, Excel 2016 for Mac, Excel for Mac 2011",

When when I try to use it, e.g. by entering "=BITAND(127,8)" I get the dreaded "#NAME?", showing that it is not in fact recognized. It does not appear as an auto-complete option while typing, in fact entering just "=BIT" generates no autocomplete suggestions.

The Microsoft Support page doesn't say anything about needing to install additional add-in packages, although I know that's sometimes an issue. (Note: apparently it was required in 2008 as this link suggests, but nothing for the 2011 version.)

Can anyone offer a suggestion to get this working?

Alternatively, I just want to obtain a decimal-to-binary conversion but unlike DEC2BIN I don't want a string of 1's and 0's in the same cell, rather I want each bit value to end up in its own cell. Perhaps parsing the DEC2BIN string would get the job done.

Thanks.

  • 1
    Are you using an English version of Excel? Every time when I'm using a localized version, I'm surprised by Microsoft having translated the function names: Dutch, German, French... – Arjan Apr 24 '16 at 21:10
  • You can “parse” the return value of DEC2BIN(A1,8) with MID(DEC2BIN(A1,8), 1, 1), MID(DEC2BIN(A1,8), 2, 1), …, MID(DEC2BIN(A1,8), 8, 1). – G-Man Apr 24 '16 at 23:16
  • Using English the English version, Yea, just ended up parsing DEC2BIN, noticed @G-man's comment afterward. Will still leave the question up for the future, in case someone comes up with a solution that enables BITAND. – sh37211 Apr 25 '16 at 3:17
2

VBA includes operators AND and OR, so you can create user-defined functions as follows:

Function Band(arg1, arg2)
    Band = arg1 And arg2
End Function

Function Bor(arg1, arg2)
    Bor = arg1 Or arg2
End Function

You can then call these, e.g., =Band(127,8), from cells.

See How do I add VBA in MS Office? for general information.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.