Académique Documents
Professionnel Documents
Culture Documents
2. Codigo de Calcular
Private Sub CommandButton1_Click()
Dim num1 As Integer
Dim num2 As Integer
num1 = Val(TextBox1)
num2 = Val(TextBox2)
If num1 > num2 Then
MsgBox "El numero " & num1 & " Es MAYOR que " & num2
Else
MsgBox "El numero " & num2 & " Es MAYOR que " & num1
End If
TextBox1 = Empty
TextBox2 = Empty
End Sub
Observaciones:
Aplicando a rangos en Excel
Crear modulo
Sub Calcular()
Dim num1 As Integer
num1 = Range("A1")
If num1 >= 6 Then
Range("B1").Select
ActiveCell.FormulaR1C1 = "APROBO"
Else
Range("B1").Select
ActiveCell.FormulaR1C1 = "REPROBO"
End If
End Sub
TUTORIAL 6
COMBOBOX Y CHECKBOX
1. En el cdigo del UserForm
2. Colocar
Otro desarrollo
Private Sub CommandButton1_Click()
If ComboBox1 = "M" Then
Range("A1").Select
ActiveCell.FormulaR1C1 = "Masculino"
End If
If ComboBox1 = "F" Then
Range("A1").Select
ActiveCell.FormulaR1C1 = "Femenino"
End If
If ComboBox1 = "O" Then
Range("A1").Select
ActiveCell.FormulaR1C1 = "Otro"
End If
End Sub
Private Sub UserForm_Activate()
UserForm1.ComboBox1.Clear
ComboBox1.AddItem "M"
ComboBox1.AddItem "F"
ComboBox1.AddItem "O"
End Sub
GRUPOS en el UserForm