Dynamic Binary to Hexadecimal Converter in Excel
One of my friend asked me to provide dynamic way of converting binary numbers in to hexadecimal numbers. Though there is already a function available in excel BIN2HEX() but my friend requested me to provide some customization in it. I tried my level best and provided him a solution. We will learn to create same format through this blog post.
10. Copy this toggle button 8 times and arrange them as shown in below figure. Toggle button 1 should be on the extreme right side, toggle button 2 on left of toggle button 1 and likewise.. toggle button 8 should be on extreme left side.
11. Double Click with the mouse left button on each of the above toggle button. This will open VBA Editor. Copy & Paste the VBA code listed below for their respective toggle buttons:
If ToggleButton3.Value = True Then
ToggleButton3.Caption = "1"
Range("L9").Value = 1
Else
ToggleButton3.Caption = "0"
Range("L9").Value = 0
End If
End Sub
If ToggleButton4.Value = True Then
ToggleButton4.Caption = "1"
Range("K9").Value = 1
Else
ToggleButton4.Caption = "0"
Range("K9").Value = 0
End If
End Sub
If ToggleButton5.Value = True Then
If ToggleButton8.Value = True Then
ToggleButton8.Caption = "1"
Range("F9").Value = 1
Else
ToggleButton8.Caption = "0"
Range("F9").Value = 0
End If
End Sub
12. Enter the data as shown in below image in Cell Range “U2:V17”
15. Insert two “Rounded Rectangle” shapes as shown in below image (Here also you can apply formatting style of your choice).
16. Select the rectangle which is on the left side and write formula in “Formula Bar” =$E$10 and press enter. Similarly select the rectangle which is on the right side and write formula in “Formula Bar” =$O$10 and press enter. We can now see that our desired output i.e. Hexadecimal Number will appear in these shapes.
YouTube Video:
Just follow below easy steps and create your own template to convert binary numbers into hexadecimal numbers.
1. Under Developer tab click on Insert command (Click here if developer tab is not visible on your ribbon).
4. Click on this toggle button and you will see “Format” tab will appear on your Ribbon. Under this tab adjust the height and width as below:
Height: 1cm
Widht: 1.65 cm
5. Toggle button will now look as shown in below image.
8. Change the “BackColor” property and “Caption” property as shown in below image:
VBA Code for Toggle Button 1:
Private Sub ToggleButton1_Click()
If ToggleButton1.Value = True Then
ToggleButton1.Caption = "1"
Range("N9").Value = 1
Else
ToggleButton1.Caption = "0"
Range("N9").Value = 0
End If
End Sub
Else
ToggleButton1.Caption = "0"
Range("N9").Value = 0
End If
End Sub
VBA Code for Toggle Button 2:
Private Sub ToggleButton2_Click()
If ToggleButton2.Value = True Then
ToggleButton2.Caption = "1"
Range("M9").Value = 1
Else
ToggleButton2.Caption = "0"
Range("M9").Value = 0
End If
End Sub
Else
ToggleButton2.Caption = "0"
Range("M9").Value = 0
End If
End Sub
VBA Code for Toggle Button 3:
Private Sub ToggleButton3_Click()If ToggleButton3.Value = True Then
ToggleButton3.Caption = "1"
Range("L9").Value = 1
Else
ToggleButton3.Caption = "0"
Range("L9").Value = 0
End If
End Sub
VBA Code for Toggle Button 4:
Private Sub ToggleButton4_Click()If ToggleButton4.Value = True Then
ToggleButton4.Caption = "1"
Range("K9").Value = 1
Else
ToggleButton4.Caption = "0"
Range("K9").Value = 0
End If
End Sub
VBA Code for Toggle Button 5:
Private Sub ToggleButton5_Click()If ToggleButton5.Value = True Then
ToggleButton5.Caption = "1"
Range("I9").Value = 1
Else
ToggleButton5.Caption = "0"
Range("I9").Value = 0
End If
End Sub
Range("I9").Value = 1
Else
ToggleButton5.Caption = "0"
Range("I9").Value = 0
End If
End Sub
VBA Code for Toggle Button 6:
Private Sub ToggleButton6_Click()
If ToggleButton6.Value = True Then
ToggleButton6.Caption = "1"
Range("H9").Value = 1
Else
ToggleButton6.Caption = "0"
Range("H9").Value = 0
End If
End Sub
If ToggleButton6.Value = True Then
ToggleButton6.Caption = "1"
Range("H9").Value = 1
Else
ToggleButton6.Caption = "0"
Range("H9").Value = 0
End If
End Sub
VBA Code for Toggle Button 7:
Private Sub ToggleButton7_Click() If ToggleButton7.Value = True Then
ToggleButton7.Caption = "1"
Range("G9").Value = 1
Else
ToggleButton7.Caption = "0"
Range("G9").Value = 0
End If
End Sub
ToggleButton7.Caption = "1"
Range("G9").Value = 1
Else
ToggleButton7.Caption = "0"
Range("G9").Value = 0
End If
End Sub
VBA Code for Toggle Button 8:
Private Sub ToggleButton8_Click()If ToggleButton8.Value = True Then
ToggleButton8.Caption = "1"
Range("F9").Value = 1
Else
ToggleButton8.Caption = "0"
Range("F9").Value = 0
End If
End Sub
12. Enter the data as shown in below image in Cell Range “U2:V17”
N9: =POWER(2,0)
M9: =POWER(2,1)
L9: = POWER(2,2)
K9: =POWER(2,3)
I9: =POWER(2,4)
H9: =POWER(2,5)
G9: =POWER(2,6)
F9: =POWER(2,7)
O9: =K9&L9&M9&N9
E9: =F9&G9&H9&I9
N11: =N9*N10
M11: =M9*M10
L11: =L9*L10
K11: =K9*K10
I11: = I9*I10
H11: =H9*H10
G11 =G9*G10
F11 =F9*F10
O10: =VLOOKUP(O9,U2:V17,2,0)
E10: =VLOOKUP(E9,U2:V17,2,0)
K9: =POWER(2,3)
I9: =POWER(2,4)
H9: =POWER(2,5)
G9: =POWER(2,6)
F9: =POWER(2,7)
O9: =K9&L9&M9&N9
E9: =F9&G9&H9&I9
N11: =N9*N10
M11: =M9*M10
L11: =L9*L10
K11: =K9*K10
I11: = I9*I10
H11: =H9*H10
G11 =G9*G10
F11 =F9*F10
O10: =VLOOKUP(O9,U2:V17,2,0)
E10: =VLOOKUP(E9,U2:V17,2,0)
14. The resulted data will now appear as shown in below image (You can apply formatting style of your choice):
Comments
Post a Comment