Difficulty with lookup tables - Binary/Hex

jonny901901

New Member
Joined
Oct 20, 2018
Messages
2
Hello all,

I ave just completed converting decimal to binary without the use of DEC2BIN. However now I am moving onto converting this concatenated 8 bit binary number into Hex, without the use of BIN2HEX.

What I have done so far is set up a vertical table with two columns, one with 16 values (0-F), and the other with each corresponding 4 bit binary equivalent.

What I ave tried is doing a Vlookup formula to look up my 8 bit binary with the values in the lookup table.

thus far I have not had any luck, as it returns the completely wrong hex value after hitting enter.

I have attached pictures with should detail what I have done thus far.

wEUX61t


If anyone could help me it would be appreciated, also if you do provide help could you please explain your steps in depth as I need to consolidate and understand this all as I'm trying to actually learn this inside out.

thank you.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
sorry the link to the pictures of my workings and formulae

https://imgur.com/a/wEUX61t

I wrote this function that can solve your problem.
While inside the Excel sheet, just press ALT + F11, a window will open, copy the following code into it (copy+paste).
Then type inside any Excel cell =BinoHex(XX), where XX can be a binary string or the address of an Excel Cell containing the binary string.
It will convert the binary to Hex and post into the Cell above.
If you want to convert binary to Decimal instead, just replace the function line at the bottom, "BinoHex = Hex(ValoVal)" with "BinoHex = ValoVal".
An error message will report into the Cell if the binary string contains other than Ones and Zeros.

Code:
Public Function BinoHex(ByVal Valo As String) As String
Dim ValoVal As Double

For N = 1 To Len(Valo)
    ValoVal = ValoVal * 2
    Bit = Left(Valo, 1)
    If Bit < 0 Or Bit > 1 Then BinoHex = "ERR: Not Binary": Exit Function
    Valo = Mid(Valo, 2)
    ValoVal = ValoVal + Bit
    Next N
BinoHex = Hex(ValoVal)

End Function
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top