This document describes how to design an Excel application to calculate the colors of a resistor based on its value. It involves:
1) Designing a grid layout
2) Naming a cell to store the resistor value
3) Copying VBA code to read the resistor value and set the colors of cells D7, F7, and H7 based on the digits in the value.
This document describes how to design an Excel application to calculate the colors of a resistor based on its value. It involves:
1) Designing a grid layout
2) Naming a cell to store the resistor value
3) Copying VBA code to read the resistor value and set the colors of cells D7, F7, and H7 based on the digits in the value.
Original Description:
Excel para calcular los valores de una resistencia.
This document describes how to design an Excel application to calculate the colors of a resistor based on its value. It involves:
1) Designing a grid layout
2) Naming a cell to store the resistor value
3) Copying VBA code to read the resistor value and set the colors of cells D7, F7, and H7 based on the digits in the value.
This document describes how to design an Excel application to calculate the colors of a resistor based on its value. It involves:
1) Designing a grid layout
2) Naming a cell to store the resistor value
3) Copying VBA code to read the resistor value and set the colors of cells D7, F7, and H7 based on the digits in the value.
Diseño de una aplicación para calcular los colores de
una resistencia
1) Diseñar el la parrilla para que tenga este aspecto
2) Seleccionar la celda F10 y en el menú insertar - nombre -- definir escribir
valorresistencia. ( esto servirá para nombrar la celda desde programa).
3) En el menú herramientas seleccionar macro y editor de visual basic
4) Copiar en el editor el siguiente código:
Option Explicit Private Sub Worksheet_Calculate() Worksheet_Change Range("valorresistencia") End Sub
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim b1 As Integer Dim b2 As Integer Dim b3 As Integer b1 = Mid$(Range("valorresistencia").Value, 1, 1) b2 = Mid$(Range("valorresistencia").Value, 2, 1) b3 = Len(Range("valorresistencia").Value) - 2 ' Determina el evento para observar una celda If Target.Address = Range("valorresistencia").Address Then
' Accion a tomar
Select Case b1 Case Is = 0 [d7].Interior.Color = RGB(0, 0, 0) Case Is = 1 [d7].Interior.Color = RGB(153, 10, 51) Case Is = 2 [d7].Interior.Color = RGB(255, 0, 0) Case Is = 3 [d7].Interior.Color = RGB(255, 153, 0) Case Is = 4 [d7].Interior.Color = RGB(255, 255, 0) Case Is = 5 [d7].Interior.Color = RGB(0, 255, 0) Case Is = 6 [d7].Interior.Color = RGB(0, 0, 255) Case Is = 7 [d7].Interior.Color = RGB(255, 51, 153) Case Is = 8 [d7].Interior.Color = RGB(204, 204, 204) Case Is = 9 [d7].Interior.Color = RGB(255, 225, 255) End Select Select Case b2 Case Is = 0 [f7].Interior.Color = RGB(0, 0, 0) Case Is = 1 [f7].Interior.Color = RGB(153, 10, 51) Case Is = 2 [f7].Interior.Color = RGB(255, 0, 0) Case Is = 3 [f7].Interior.Color = RGB(255, 153, 0) Case Is = 4 [f7].Interior.Color = RGB(255, 255, 0) Case Is = 5 [f7].Interior.Color = RGB(0, 255, 0) Case Is = 6 [f7].Interior.Color = RGB(0, 0, 255) Case Is = 7 [f7].Interior.Color = RGB(255, 51, 153) Case Is = 8 [f7].Interior.Color = RGB(204, 204, 204) Case Is = 9 [f7].Interior.Color = RGB(255, 225, 255) End Select Select Case b3 Case Is = 0 [h7].Interior.Color = RGB(0, 0, 0) Case Is = 1 [h7].Interior.Color = RGB(153, 10, 51) Case Is = 2 [h7].Interior.Color = RGB(255, 0, 0) Case Is = 3 [h7].Interior.Color = RGB(255, 153, 0) Case Is = 4 [h7].Interior.Color = RGB(255, 255, 0) Case Is = 5 [h7].Interior.Color = RGB(0, 255, 0) Case Is = 6 [h7].Interior.Color = RGB(0, 0, 255) Case Is = 7 [h7].Interior.Color = RGB(255, 51, 153) Case Is = 8 [h7].Interior.Color = RGB(204, 204, 204) Case Is = 9 [h7].Interior.Color = RGB(255, 225, 255) End Select End If
End Sub
5) Desbloquear la celda F10 y proteger la aplicación activando “Formato de celdas”,