Вы находитесь на странице: 1из 12

Ejemplos de formulario en Excel

Dim dia, mes, año As Variant


Dim diae, mese, añoe As Variant
Dim item, descripcion, material,
cantidad, medida, acabado As Variant
Dim OT, OC, CLIENTE As Variant
Dim respuesta, rubro As Variant
Dim contador, n, maximo, numero As
Integer

Private Sub
CommandButton10_Click()
Sheets("FORMATO DE OT").Select

ult1 = (Cells(Rows.Count,
2).End(xlUp).Row)
ult1 = ult1 + 1
Cells(ult1, 2) = Label20
Cells(ult1, 3) = Label21
Cells(ult1, 4) = Label22
Cells(ult1, 5) = Label23
Cells(ult1, 6) = Label24
Cells(ult1, 7) = Label26

1
End Sub

Private Sub CommandButton11_Click()


Sheets("REGISTRO DE INGRESO DE OT").Select

ult1 = (Cells(Rows.Count, 1).End(xlUp).Row)


ult1 = ult1 + 1
Cells(ult1, 4) = Label20
Cells(ult1, 5) = Label21
Cells(ult1, 6) = Label22
Cells(ult1, 7) = Label23
Cells(ult1, 8) = Label26
Cells(ult1, 9) = Label24

End Sub

Private Sub CommandButton12_Click()


If ComboBox10.Text = "" Then
MsgBox "Ingrese el tipo de acabado"
Else
Label25 = ComboBox10.Text
End If
End Sub

Private Sub CommandButton13_Click()


Sheets("REGISTRO DE INGRESO DE OT").Select

ult1 = (Cells(Rows.Count, 3).End(xlUp).Row)


ult1 = ult1 + 1
Cells(ult1, 1) = TextBox1.Text
Cells(ult1, 2) = Label14
Cells(ult1, 3) = TextBox2.Text

End Sub

Private Sub CommandButton14_Click()


UserForm2.Hide
End Sub

Private Sub CommandButton3_Click()

dia = ComboBox1.Text
mes = ComboBox2.Text
año = ComboBox3.Text
diae = ComboBox4.Text
mese = ComboBox5.Text
añoe = ComboBox6.Text

If dia = "" Or mes = "" Or año = "" Or diae = "" Or mese = "" Or añoe = "" Then
MsgBox ("Ingrese todos los datos")
2
Else
respuesta = MsgBox("¿Los datos ingresados son correctos?", vbYesNo, "Confirmación de datos")
Select Case respuesta
Case vbYes
With Worksheets("FORMATO DE OT")
.Range("F3").Value = dia
.Range("G3").Value = mes
.Range("H3").Value = año
.Range("F4").Value = diae
.Range("G4").Value = mese
.Range("H4").Value = añoe
End With
Case vbNo
MsgBox "Vuelva a ingresar los datos"
End Select
End If

End Sub

Private Sub CommandButton4_Click()

CLIENTE = TextBox3.Text
OT = TextBox1
OC = TextBox2

If CLIENTE = "" Or OT = "" Or OC = "" Then


MsgBox ("Ingrese todos los datos")
Else
respuesta = MsgBox("¿Los datos ingresados son correctos?", vbYesNo, "Confirmación de datos")

Select Case respuesta


Case vbYes
With Worksheets("FORMATO DE OT")
.Range("C3").Value = CLIENTE
.Range("C4").Value = OT
.Range("C5").Value = OC
End With
Case vbNo
MsgBox "Vuelva a ingresar los datos"
End Select

End If

End Sub

Private Sub CommandButton5_Click()

If TextBox4.Text = "" Then


MsgBox "Ingrese el número de Item"
Else
3
Label20 = TextBox4.Text
End If

End Sub

Private Sub CommandButton6_Click()


If TextBox5.Text = "" Then
MsgBox "Ingrese la descripción"
Else
Label21 = TextBox5.Text
End If
End Sub

Private Sub CommandButton7_Click()


If TextBox6.Text = "" Then
MsgBox "Ingrese las medidas"
Else
Label22 = TextBox6.Text
End If
End Sub

Private Sub CommandButton8_Click()


If TextBox7.Text = "" Then
MsgBox "Ingrese la cantidad"
Else
Label23 = TextBox7.Text
End If
End Sub

Private Sub CommandButton9_Click()


If ComboBox9.Text = "" Then
MsgBox "Ingrese el tipo de material"
Else
Label24 = ComboBox9.Text
End If
End Sub

Private Sub UserForm_Activate()

Sheets("Clientes").Select
ult = Cells(Rows.Count, 2).End(xlUp).Row
For n = 2 To ult
ComboBox7.AddItem (Cells(n, 2).Text)
Next n

'Select Case rubro


'Case "AGREGADOS"
'ult = Cells(Rows.Count, 4).End(xlUp).Row
'For n = 2 To ult
'ComboBox8.AddItem (Cells(n, 4).Text)
' Next
4
'Case "AGROINDUSTRIA"
ult = Cells(Rows.Count, 10).End(xlUp).Row
For n = 2 To ult
ComboBox8.AddItem (Cells(n, 10).Text)
Next

'Case "INDUSTRIAS GENERALES"


' ult = Cells(Rows.Count, 16).End(xlUp).Row
' For n = 2 To ult
' ComboBox8.AddItem (Cells(n, 16).Text)
' Next

'Case "ASTILLERO"
' ult = Cells(Rows.Count, 22).End(xlUp).Row
' For n = 2 To ult
' ComboBox8.AddItem (Cells(n, 22).Text)
' Next

'Case "METALMECÁNICA"
' ult = Cells(Rows.Count, 28).End(xlUp).Row
'For n = 2 To ult
' ComboBox8.AddItem (Cells(n, 28).Text)
' Next

'Case "MINERA"
' ult = Cells(Rows.Count, 43).End(xlUp).Row
' For n = 2 To ult
' ComboBox8.AddItem (Cells(n, 34).Text)
' Next

'Case "PESCA"
' ult = Cells(Rows.Count, 40).End(xlUp).Row
'For n = 2 To ult
'ComboBox8.AddItem (Cells(n, 40).Text)
' Next

'Case "PERSONAS NATURALES"


' ult = Cells(Rows.Count, 46).End(xlUp).Row
'For n = 2 To ult
' ComboBox8.AddItem (Cells(n, 46).Text)
' Next

'Case "FUNDICIÓN"
' ult = Cells(Rows.Count, 52).End(xlUp).Row
' For n = 2 To ult
' ComboBox8.AddItem (Cells(n, 52).Text)
' Next

'Case "HIDROSTÁTICA"
' ult = Cells(Rows.Count, 58).End(xlUp).Row
5
' For n = 2 To ult
' ComboBox8.AddItem (Cells(n, 58).Text)
' Next

'End Select

Sheets("Datos").Select
ult = Cells(Rows.Count, 1).End(xlUp).Row
For n = 2 To ult
ComboBox1.AddItem (Cells(n, 1).Text)
Next n

Sheets("Datos").Select
ult = Cells(Rows.Count, 2).End(xlUp).Row
For n = 2 To ult
ComboBox2.AddItem (Cells(n, 2).Text)
Next n

Sheets("Datos").Select
ult = Cells(Rows.Count, 3).End(xlUp).Row
For n = 2 To ult
ComboBox3.AddItem (Cells(n, 3).Text)
Next n

Sheets("Datos").Select
ult = Cells(Rows.Count, 1).End(xlUp).Row
For n = 2 To ult
ComboBox4.AddItem (Cells(n, 1).Text)
Next n

Sheets("Datos").Select
ult = Cells(Rows.Count, 2).End(xlUp).Row
For n = 2 To ult
ComboBox5.AddItem (Cells(n, 2).Text)
Next n

Sheets("Datos").Select
ult = Cells(Rows.Count, 3).End(xlUp).Row
For n = 2 To ult
ComboBox6.AddItem (Cells(n, 3).Text)
Next n

Sheets("Datos").Select
ult = Cells(Rows.Count, 4).End(xlUp).Row
For n = 2 To ult
ComboBox9.AddItem (Cells(n, 4).Text)
Next n

Sheets("Datos").Select
ult = Cells(Rows.Count, 5).End(xlUp).Row
6
For n = 2 To ult
ComboBox10.AddItem (Cells(n, 5).Text)
Next n

End Sub

Private Sub CommandButton1_Click()

If ComboBox7.Text = "" Then


MsgBox "Seleccione un rubro"
Else
Label13 = ComboBox7.Text
rubro = ComboBox7.Text
End If

End Sub

Private Sub CommandButton2_Click()


If ComboBox8.Text = "" Then
MsgBox "Seleccione un cliente"
Else
Label14 = ComboBox8.Text
End If

End Sub

Private Sub CommandButton1_Click()

7
x = 4 + CInt(TextBox1.Text) - 1
Cells(x, 1) = TextBox1.Text
Cells(x, 2) = TextBox2.Text
Cells(x, 3) = TextBox3.Text
Cells(x, 4) = TextBox4.Text

If OptionButton1.Value = True Then


Cells(x, 5) = OptionButton1.Caption

End If

If OptionButton2.Value = True Then


Cells(x, 5) = OptionButton2.Caption
End If

Cells(x, 6) = TextBox5.Text
Cells(x, 7) = TextBox6.Text
Cells(x, 8) = TextBox7.Text
Cells(x, 9) = TextBox8.Text
Cells(x, 10) = TextBox9.Text

Unload UserForm2

End Sub

Private Sub CommandButton2_Click()


Unload UserForm2
End Sub

8
9
10
11
12

Вам также может понравиться