Binary code formula help

serge

Well-known Member
Joined
Oct 8, 2008
Messages
1,446
Office Version
  1. 2007
Platform
  1. Windows
Hi everyone,

I have this formula :

=DEC2BIN(MOD(A1,2^20)/2^16,4)&DEC2BIN(MOD(A1,2^16)/2^8,8)&DEC2BIN(MOD(A1,2^8),8)

What I'm looking for is (2) formulas.

One that will give me a total of 6 digits no matter what the number to transfer is from 1 to 63.

Example : 1 would show : 000001
23 would show : 010111

and the second a total of 7 digits, same thing 1 to 127.

Thank you, Serge.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Take a look at the second argument for the DEC2BIN function. It allows you to specify the number of binary digits desired.
 
Upvote 0
I tried to change the 20 to a 6 or 7, but it wouldn't change anything if that what you refer ?
That's why I ask for help I don't know how to make it happen ??
 
Upvote 0
Try DEC2BIN(your formula,7) to get a 7 digit result. But based on your comment "I tried to change the 20 to a 6 or 7" I am unsure what your are trying to accomplish. Give us an explaination of the goal of your formula and perhaps we can help.
 
Upvote 0
Thanks for the reply West Man,

What I need is that the formula give me in return a total of 6 digits, if I want to get the binary code of the number 1, I need it to be 000001 and not just 1 like : =DEC2BIN(A1) would give me, or if I want the binary code of the number 15, I need the return to be 001111 and not 1111.

That's all, but I don't know how to change the formula !!!
 
Upvote 0
Thank you West Man, it works, I appreciate the help.
Serge.
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,696
Members
452,938
Latest member
babeneker

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