Convert Binary to Hex

G

Guest

Yes. I can do it with 8 digits and some others but i need to convert a 12
digit binary number to hex. example: cell f11 has: 010101010101 what i
have is =bin2hex(F11) and it doesn work.
 
G

Guest

Wonderful that works great. Now the long pass.... Can we do it with a 32
bit binary number?

Thanks.
 
M

Michel Pierron

Hi Chipmunk,

Function BinToHex(Binary As String)
Dim Value&, i&, Base#: Base = 1
For i = Len(Binary) To 1 Step -1
Value = Value + IIf(Mid(Binary, i, 1) = "1", Base, 0)
Base = Base * 2
Next i
BinToHex = Hex(Value)
End Function

MP
 
G

Guest

Thanks for the response. I opened up the vb editor and pasted in your code.
What do I need to put in the worksheet cell?

Thanks.
 
M

Michel Pierron

Hi Chipmunk,
This code must be in a standard module.
In worksheet cell:
=
In ComboBox Functions: select Other functions
In ComboBox Categories: Select Personalized
In ListBox Functions: Select BinToHex

Regards,
MP
 
G

Guest

Michel,
I sincerly appreciate all your help. But....I'm must be green here. I'm
not getting what your saying to do 100 percent. Can explain so that I might
better understand.

Thanks,
Benny
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top