Trying to create a Hexadecimal to Decimal Binary Input

shyy

Well-known Member
Hey guys,

I am having trouble with an excel formula that should be easy. For some reason I can't think straight today and have done more complex formulas in the past. What I want to do is have a user input a number (0-9,A-F) which is a hexadecimal into a binary number by putting a bunch of if statements, so if a user puts A in cell A1, then put the number 10.

What I have is this, but it comes out true/false and not the numbers 10 or 12.

If I do for one letter, then it would work but when I try to do a OR statement thats where its comes out either true or false.

=OR(IF(TEXT(A1="A",1),10,0),IF(TEXT(A1="B",1),11,0))

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Try

=HEX2DEC(A1)

shyy

Well-known Member
Thanks VoG!!!

But can you still correct my formula to get two if with or functions to work correctly.

barry houdini

MrExcel MVP
You wouldn't use OR, the syntax, for just A and B would be like this

=IF(A1="A",10,IF(A1="B",11,""))

but you can't nest 16 IFs (unless you have Excel 2007) so you might want to add them like this

=IF(A1="A",10)+IF(A1="B",11)+IF(A1="C",12)

or you could use MATCH like this

=MATCH(A1,{0,1,2,3,4,5,6,7,8,9,"A","B","C","D","E","F"},0)-1

Replies
6
Views
805
Replies
3
Views
365
Replies
1
Views
321
Replies
3
Views
246
Replies
2
Views
2K

1,190,782
Messages
5,982,888
Members
439,804
Latest member
melD94

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.

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

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