Break single hexadecimal number up into its 4 binary components

AnotherSami

New Member
Joined
Aug 1, 2022
Messages
1
Office Version
  1. 2019
Platform
  1. Windows
Hello all,

I am trying to convert a single hexadecimal number into its 4 constituent binary bits in 4 different columns while preserving the leading zeros. I have seen multiple answers on this and other forums, but non preserve the leading zeros.

below is an example of what I am trying to do. If I have the 0x1 i want to return 0001 in 4 different columns. Same with 0x4 returning 0100 ... and so on.

lmk04208 Registers.txt
NOPQR
33hexB3B2B1B0
3410001
3540100
3660110
37F1111
lmk04208 Registers


Thanks in advance!
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
In O34 and filled right/down, try:

=MID(TEXT(HEX2BIN($N34),"0000"),COLUMN(A1),1)

The "A1" reference returns 1, 2, 3 and 4 when dragged across (for binary digits 1-4), so don't change that to N1.
 
Upvote 0
tmptest.xlsm
ABCDE
1hexB3B2B1B0
210001
340100
460110
5F1111
Sheet3
Cell Formulas
RangeFormula
B2:B5B2=LEFT(HEX2BIN($A2,4),1)
C2:C5C2=MID(HEX2BIN($A2,4),2,1)
D2:D5D2=MID(HEX2BIN($A2,4),3,1)
E2:E5E2=RIGHT(HEX2BIN($A2,4),1)
 
Upvote 0
Ah, didn't realize hex2bin had a second argument... haha. You can then use the MID formula for all places like in my original, without the TEXT bits and no need to use four different formulas.

=MID(HEX2BIN($N1,4),COLUMN(A1),1)
 
Upvote 0
Solution

Forum statistics

Threads
1,215,731
Messages
6,126,537
Members
449,316
Latest member
sravya

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