When we work with digital systems, IoT logs, or hardware configurations, binary data is most of the time part of the workflow. Binary to decimal conversion is the process of translating a number from base-2 (binary) to base-10 (decimal). Computers store data in binary, while humans generally use decimals. This conversion is necessary to interpret or process binary-based outputs meaningfully in Excel and particularly when we work with technical or digital data.
To convert binary to decimal, follow these steps:
➤ Enter your binary number in a cell (e.g., A2).
➤ Use the following formulas: =BIN2DEC(A2) for up to 10-bit binaries.
➤ Press Enter to view the decimal output.
In this article we will show methods like BIN2DEC, DECIMAL, and a custom VBA function to convert binary to decimal in excel.
Using BIN2DEC Function to Convert Binary to Decimal in Excel
The BIN2DEC function converts binary numbers into their decimal equivalents in Excel. It is good to use for datasets like encoded employee access codes or digital signal data. Use this method when your binary values are 10 digits or fewer and stored in one column (e.g., Column A).
We have taken a dataset that represents binary access codes used in a workplace security system. We will convert each binary code to decimal value using Excel’s BIN2DEC function.
Steps:
➤ Open your dataset. We have Binary Access Code in Column A. We will store the converted decimal values in Column B.
➤ In Cell B2 type the formula and press Enter:
=BIN2DEC(A2)
It will convert the binary value from A2 to decimal. For example here it converts the Binary value 10110 into decimal value 44
➤ Click cell B2, then drag the fill handle down to fill the formula for the rest of the cells.
Applying Custom SUMPRODUCT Formula to Convert binary to Decimal in Excel
This method uses a combination of Excel functions like SUMPRODUCT, MID, ROW, and INDIRECT to parse each binary digit and calculate its decimal equivalent. It is best when binary numbers exceed 10 bits.
Steps:
➤ Open your dataset that has binary values to convert. .We have Binary access code in column B. We will store the converted values in column C
➤ Type the following formula in cell C2 and press Enter.
=SUMPRODUCT(MID(B2,ROW(INDIRECT("1:"&LEN(B2))),1)*2^(LEN(B2)-ROW(INDIRECT("1:"&LEN(B2)))))
The decimal equivalent will display in C2.
➤ Drag the fill handle (small square at the bottom-right corner of C2) downwards to apply the formula to the other rows.
Use of the DECIMAL Function to Convert Binary to Decimal in Excel
The DECIMAL function in Excel is a versatile method for converting binary strings to decimal numbers. Unlike BIN2DEC, this function can handle binary numbers longer than 10 bits which makes it helpful for data from IoT devices, barcodes, or custom binary-encoded systems.
We have a dataset that comes from an IoT system where sensors generate binary output values. We will convert these binary values into decimal values using the DECIMAL function.
Steps:
➤Open your dataset. In our dataset we have a binary sensor reading data in Column A. While we store the converted decimal Sensor value in column B.
➤ Type the formula and press Enter.
=DECIMAL(A2, 2).
This will convert the binary text from A2 to a decimal number in B2.
➤ Drag the fill handle (small square at the bottom-right corner of cell B2) down to apply the formula to rest of the cells
Applying a Custom VBA Function to Convert Binary to Decimal in Excel
This method uses a custom VBA function to convert binary strings of any length into decimal numbers. It is best when dealing with binary-encoded serial numbers, device IDs, or encrypted data that exceed 10 or even 32 bits. You can use this when Excel’s built-in BIN2DEC or DECIMAL functions can’t handle the binary input.
We have a dataset that contains binary-encoded product serial numbers used in a hardware manufacturer’s inventory system. The binary strings exceed 24 bits and cannot be converted using regular Excel functions. We will use a custom VBA function to handle long binary numbers and convert them to decimals for backend integration.
Steps:
➤ Open the Excel workbook, press Alt + F11 to open the VBA Editor window. Go to Insert > Module.
➤ A blank code window will open. Paste the following VBA code in the module window. Then press Ctrl + S and close the VBA window
Function BinToDec(binStr As String) As Double
Dim i As Long
Dim result As Double
result = 0
For i = 1 To Len(binStr)
If Mid(binStr, i, 1) = "1" Then
result = result + 2 ^ (Len(binStr) - i)
End If
Next i
BinToDec = result
End Function
➤ In cell B2 type: =BinToDec(A2) and press Enter to see the decimal value.
➤ Use the fill handle to copy the formula down the column. Then Column B is filled with converted decimal values.
Frequently Asked Questions
How to convert a binary number to decimal in Excel?
You can use:
- =BIN2DEC(A2) for binary values up to 10 digits.
- =DECIMAL(A2, 2) for longer binary strings.
- =BinToDec(A2) using a custom VBA function.
How to convert a number A2 into a binary in Excel?
Use the formula: =DEC2BIN(A2). This converts a decimal number into its binary equivalent.
What if my binary number exceeds 10 bits?
Use the =DECIMAL(A2, 2) function or a VBA-based method like BinToDec(A2) to bypass the 10-bit limit of BIN2DEC.
What if the number is not a valid binary number?
All methods will return an error if the value contains non-binary digits (anything other than 0 or 1). Always validate input before applying formulas.
Concluding Words
We have shown four very useful methods. If you use Excel’s built-in BIN2DEC, the flexible DECIMAL function, or a custom VBA solution, converting binary to decimal in Excel is easy and efficient. Each method suits different use cases: short binary values, long binary strings, or full customization with VBA.