You are on page 1of 6

Sub bin2des()

hex01 = Cells(1, 1) * 8 + Cells(1, 2) * 4 + Cells(1, 3) * 2 + Cells(1, 4) * 1

hex02 = Cells(1, 5) * 8 + Cells(1, 6) * 4 + Cells(1, 7) * 2 + Cells(1, 8) * 1

hex03 = Cells(1, 9) * 8 + Cells(1, 10) * 4 + Cells(1, 11) * 2 + Cells(1, 12) * 1

hex04 = Cells(1, 13) * 8 + Cells(1, 14) * 4 + Cells(1, 15) * 2 + Cells(1, 16) * 1

dec = hex01 * 16^ ^ 3 + hex02 * 16^ ^ 2 + hex03 * 16^ ^ 1 + hex04 * 16^ ^ 0

Cells(3, 1) = dec

If (hex01 = 10) Then

hex01 = "A"

End If

If (hex01 = 11) Then

hex01 = "B"

End If

If (hex01 = 12) Then

hex01 = "C"

End If
If (hex01 = 13) Then

hex01 = "D"

End If

If (hex01 = 14) Then

hex01 = "E"

End If

If (hex01 = 15) Then

hex01 = "F"

End If

Cells(2, 1) = hex01

If (hex02 = 10) Then

hex02 = "A"

End If

If (hex02 = 11) Then

hex02 = "B"

End If
If (hex02 = 12) Then

hex02 = "C"

End If

If (hex02 = 13) Then

hex02 = "D"

End If

If (hex02 = 14) Then

hex02 = "E"

End If

If (hex02 = 15) Then

hex02 = "F"

End If

Cells(2, 5) = hex02

If (hex03 = 10) Then

hex03 = "A"

End If

If (hex03 = 11) Then


hex03 = "B"

End If

If (hex03 = 12) Then

hex03 = "C"

End If

If (hex03 = 13) Then

hex03 = "D"

End If

If (hex03 = 14) Then

hex03 = "E"

End If

If (hex03 = 15) Then

hex03 = "F"

End If

Cells(2, 9) = hex03

If (hex04 = 10) Then

hex04 = "A"
End If

If (hex04 = 11) Then

hex04 = "B"

End If

If (hex04 = 12) Then

hex04 = "C"

End If

If (hex04 = 13) Then

hex04 = "D"

End If

If (hex04 = 14) Then

hex04 = "E"

End If

If (hex04 = 15) Then

hex04 = "F"

End If

Cells(2, 13) = hex04


End Sub

Sub des2bin()

des = Cells(5, 1)

des01 = Cells(5, 1)

hex01 = ""

bin = ""

While des > 0

bin = Str(des Mod 2) & bin

des = des \ 2

Wend

Cells(7, 1) = bin

hex01 = Evaluate("DEC2HEX(" & des01 & ")")

Cells(6, 1) = hex01

End Sub

You might also like