convert binary to decimal

  • Thread starter Thread starter Krishnakanth
  • Start date Start date
K

Krishnakanth

i have given the folloing command in one of the cell.

=BIN2DEC(1100100)

When I hit enter i am getting the following text.

#NAME?

Can anyone help me fix this problem.

Krishnakanth M
 
Here is a UDF that you can use.

Function BIN2DEC(data As Variant) As Variant

If Not IsNumeric(data) Then
data = Format(data, "text")
Else
data = Trim(data)
End If
BIN2DEC = 0
Do While data <> ""
NewChar = Left(data, 1)
data = Mid(data, 2)
Select Case NewChar
Case "0"
BIN2DEC = 2 * BIN2DEC
Case "1"
BIN2DEC = (2 * BIN2DEC) + 1
Case Else
BIN2DEC = "Not Binary"
End Select
Loop

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top