Does anyone know how to display a 4digit HEX value as as Binary in Excel?
Excel only seems to have an accuracy of 10 Binary digits.
Does anyone know how to display a 4digit HEX value as as Binary in Excel?
Excel only seems to have an accuracy of 10 Binary digits.
Last edited by dcloney; 03-15-2011 at 09:53 AM.
Welcome to the forum.
How about a UDF?
Copy the code to a code module and the apply as, for example,Function HexToBin(ByVal sHex As String, _ Optional ByVal iLen As Long = 0, _ Optional sSep As String = "") As String ' shg 2007 ' sSep is the nybble separator ' no error checking for invalid characters ... Const s As String = "0000000100100011010001010110011110001001101010111100110111101111" Dim i As Long sHex = Replace(sHex, " ", "") If iLen <= 0 Then iLen = 4 * Len(sHex) For i = 1 To Len(sHex) HexToBin = HexToBin & sSep & Mid(s, 4 * ("&H" & Mid(sHex, i, 1)) + 1, 4) Next i HexToBin = WorksheetFunction.Rept(sSep & "0000", iLen \ 4) & HexToBin HexToBin = Right(HexToBin, iLen + (Len(sHex) - 1) * Len(sSep)) End Function
=HexToBin("ABCD")
Adding a Macro to a Code Module
1. Copy the code from the post
2. Press Alt+F11 to open the Visual Basic Editor (VBE)
3. From the menu bar in the VBE window, do Insert > Module
4. Paste the code in the window that opens
5. Press Alt+Q to close the VBE and return to Excel
Entia non sunt multiplicanda sine necessitate
No luck im afraid.
Cheers for the help
Last edited by shg; 03-15-2011 at 03:50 PM. Reason: deleted spurious quote
l;lhklhkjghghjklghyjkl
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks