How to Convert Decimals to Binary in Excel – 3 Methods

Consider the dataset containing a List of Decimal Numbers.

To convert these decimal numbers into binary numbers:

dataset for excel decimal to binary

 


Method 1 – Using the DEC2BIN Function

Steps:

  • Go to C5 >> enter the formula >> use the Fill Handle Tool to copy the formula into the cells below.

=DEC2BIN(B5)

B5 refers to the value of a “Decimal Number” : 10.

Using the DEC2BIN Function

This is the output.


Method 2 – Utilizing the INT and MOD Functions

Steps:

  • Select C5 >> enter the formula.

=INT(B5/2)

 B5 indicates the “Decimal Number”: 40.

 Utilizing INT and MOD Functions

  • Go to the adjacent D5 >> use the equation below.

=MOD(B5,2)

B5 represents the “Decimal Number” :“40” and 2 is the divisor.

Using MOD function

  • Enter the following equation in C6.

=INT(C5/2)

C5 is the “Quotient”: 20.

  • Copy the formula into D6.

=MOD(C6,2)

C6 is the “Quotient”: 10.

  • Use the Fill Handle tool to apply the formula to the cells below.
  • Go to C10.
  • Copy and paste the expression in the Formula Bar.

=CONCATENATE(TRANSPOSE(INDEX(D5:D9,N(IF({1},ROWS(D5:D9)-ROW(D5:D9)+MIN(ROW(D5:D9)))))))

Formula Breakdown:

  • ROW(D5:D9) → the ROW function returns the row number of a reference. Here, D5:D9 points to the reference argument.
    • Output → {5;6;7;8;9}
  • MIN(ROW(D5:D9)) → the MIN function returns the smallest number in the {5;6;7;8;9} range: 5.
    • Output → 5
  • ROWS(D5:D9)-ROW(D5:D9)+MIN(ROW(D5:D9))
    •  5 – {5;6;7;8;9} + 5 → {5;4;3;2;1}
  • IF({1},ROWS(D5:D9)-ROW(D5:D9)+MIN(ROW(D5:D9))) → the IF function checks whether a condition is met. Here, {1} is the logical_test argument which represents TRUE.  The function returns the value_if_false argument: ROWS(D5:D9)-ROW(D5:D9)+MIN(ROW(D5:D9)).
    • Output → {5;4;3;2;1}
  • INDEX(D5:D9,N(IF({1},ROWS(D5:D9)-ROW(D5:D9)+MIN(ROW(D5:D9))))) → the INDEX function returns a value at the intersection of a row and column in a given range.  D5:D9 is the array argument, and N(IF({1},ROWS(D5:D9)-ROW(D5:D9)+MIN(ROW(D5:D9)))) is the row_num argument that indicates the row location.
    • Output → {1;1;0;0;1}
  • TRANSPOSE(INDEX(D5:D9,N(IF({1},ROWS(D5:D9)-ROW(D5:D9)+MIN(ROW(D5:D9)))))) → the TRANSPOSE function converts a vertical range of cells to a horizontal range. Here, INDEX(D5:D9,N(IF({1},ROWS(D5:D9)-ROW(D5:D9)+MIN(ROW(D5:D9))))) is the array argument.
    • Output → {1,1,0,0,1}
  • CONCATENATE(TRANSPOSE(INDEX(D5:D9,N(IF({1},ROWS(D5:D9)-ROW(D5:D9)+MIN(ROW(D5:D9))))))) → the CONCATENATE function joins several strings.
    • Output → {“1″,”1″,”0″,”0″,”1”}

Applying Formula into the Formula Bar

  • Select the highlighted part of the formula.
  • Press F9.

Selecting Formula and pressing F9 key

This is the output.

  • Remove the curly brackets.
  • Press ENTER.

Removing Curly Brackets

Observe the GIF below.

excel decimal to binary Utilizing INT and MOD Functions

This is the final output:

excel decimal to binary using the INT and MOD functions


Method 3 – Using the Quotient and the MOD Functions

Steps:

  • Follow the steps shown in the previous method. Instead of the INT function, use the QUOTIENT function.

Employing Quotient and MOD Functions

  • Copy C4:D9.
  • Move the cursor to B11.
  • Click Paste.
  • Choose Values & Source Formatting.

Pasting with Value and Source formatting

  • Select B12:C16.
  • Go to the Data tab >> click Sort >> in Sort by, choose Quotient >> select Smallest to Largest Order.

Sorting data smallest to largest

  • Enter the formula below in C17.

=CONCATENATE(C13,C14,C15,C16,C17)

In the above formula, C13, C14, C15, C16, and C17 represent the sorted “Remainder” values.

excel decimal to binary using the QUOTIENT, MOD, and CONCATENATE functions


How to Convert Text to Binary in Excel

Convert the “Employee Names”  into binary numbers:

Dataset for How to Convert Text to Binary in Excel

Steps:

  • Go to the Developer tab >> click Visual Basic.

Go to developer tab

In the Visual Basic Editor:

  • Select Insert >> choose Module.

Inserting Module

Copy the code and paste it into the window.

Public Function String_To_Binary(str As String) As String
    Dim j As Long, lng As Long

    lng = Len(str)
    With Application.WorksheetFunction
        For j = 1 To lng
            String_To_Binary = String_To_Binary & .Dec2Bin(Asc(Mid(str, j, 1)))
        Next j
    End With
End Function

VBA code for excel text to binary

Code Breakdown:

  • The function is given a name, here String_To_Binary().
  • Define the variables j and lng and assign the data type: Long.
  • Use the Len function to determine the length of the argument.
  • Use the For Loop to loop through each text in the string and use the DEC2BIN and MID functions to convert the text to binary numbers.

VBA Code explanation

  • Go to D5 >> use the function:

=String_To_Binary(C5)

C5 indicates the “Employee Name Jim”.

excel text to binary with VBA Code


Practice Section

Practice here.

Practice Section for excel decimal to binary


Download Practice Workbook


<< Go Back to | Excel Number System Conversion | Excel for Math | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Eshrak Kader
Eshrak Kader

Eshrak Kader is a dedicated professional with a BSc. Degree in Naval Architecture and Marine Engineering from Bangladesh University of Engineering and Technology. He boasts a rich background in Microsoft Office Suite, and over the past year, he has authored over 120 insightful articles for the ExcelDemy. Currently, Eshrak leads a team of 5 in the ExcelDemy Video project and enjoys problem-solving and making videos on Excel. Eshrak’s passion for continuous learning underscores his commitment to excellence in... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo