domingo, 1 de julio de 2018

VBA FORMULARIOS Práctica 8B

CÓDIGO DE PRIMER FORMULARIO

Private Sub CommandButton1_Click()
Sheets("Hoja2").Select
Ult = Cells(Rows.Count, 1).End(xlUp).Row
Cells(Ult + 1, 1) = TextBox1.Text
Cells(Ult + 1, 2) = TextBox2.Text
Cells(Ult + 1, 3) = TextBox3.Text
Cells(Ult + 1, 4) = ComboBox1.Text
Cells(Ult + 1, 6) = TextBox4.Text
Cells(Ult + 1, 7) = TextBox5.Text

If OptionButton1.Value = True Then
    Cells(Ult + 1, 5) = OptionButton1.Caption
End If
If OptionButton2.Value = True Then
    Cells(Ult + 1, 5) = OptionButton2.Caption
    End If
If OptionButton3.Value = True Then
    Cells(Ult + 1, 5) = OptionButton3.Caption
   
End If


If OptionButton4.Value = True Then
    Cells(Ult + 1, 8) = OptionButton4.Caption
End If
If OptionButton5.Value = True Then
    Cells(Ult + 1, 8) = OptionButton5.Caption
    End If
   
    TextBox1.Text = ""
    TextBox2.Text = ""
    TextBox3.Text = ""
    TextBox4.Text = ""
    TextBox5.Text = ""
    ComboBox1.Text = ""
   
   
    OptionButton1.Value = False
   OptionButton2.Value = False
   OptionButton3.Value = False
   OptionButton4.Value = False
    OptionButton5.Value = False
   
   
End Sub

   Private Sub CommandButton2_Click()
    TextBox5.Value = TextBox4.Value * 12

End Sub



Private Sub UserForm_Activate()
Ult = Cells(Rows.Count, 1).End(xlUp).Row
For x = 2 To Ult
  ComboBox1.AddItem (Cells(x, 1))

Next

End Sub

CÓDIGO DE FORMULARIO II

Private Sub CommandButton1_Click()
Unload UserForm2
End Sub

No hay comentarios.:

Publicar un comentario