Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
dato = TextBox1.Value
contarsi = Application.WorksheetFunction.CountIf(Sheets("REGISTROS").Columns(1), dato)
If contarsi = 1 Then
MsgBox "El código ya existe, no se permiten duplicados"
TextBox1.SetFocus
Exit Sub
End If
Dim lr As Long
If TextBox3.Value = "" Or ComboBox1.Value = "" Or ComboBox2.Value = "" Then
MsgBox "Existen campos en blanco.Completelos!"
Cancel = False
Exit Sub
End If
If TextBox1.Value <> "" And ComboBox1.ListIndex > -1 And ComboBox2.ListIndex > -1 Then
'
With Sheets("REGISTROS")
lr = .Range("A" & Rows.Count).End(3).Row + 1
.Range("A" & lr).Value = TextBox1
.Range("D" & lr).Value = TextBox3
.Range("B" & lr).Value = ComboBox1
.Range("C" & lr).Value = ComboBox2
.Range("E" & lr).Value = Date
.Range("F" & lr).Value = 1
.Range("G" & lr).Value = ComboBox3
.Range("H" & lr).Value = Now
.Range("I" & lr).Value = ComboBox4
.Range("j" & lr).Value = TextBox6
Set h1 = Sheets("REGISTROS")
u = h1.Range("A" & Rows.Count).End(xlUp).Row
TextBox4 = h1.Range("A" & u)
End With
TextBox1.Value = ""
Cancel = True
End If
End Sub
Private Sub UserForm_Activate()
With ComboBox1
.AddItem "Mañana"
.AddItem "Tarde"
.AddItem "Noche"
.TabIndex = 0
.SetFocus
End With
'
With ComboBox2
.AddItem "Andreani"
.AddItem "Mercado libre"
.AddItem "Retiro en tienda"
.TabIndex = 1
End With
With ComboBox3
.AddItem "5458 - LA PLATA"
.AddItem "5747 - MENDOZA"
.AddItem "6063 - QUILMES"
.AddItem "72 - CITY BELL"
.AddItem "90 - BAHIA BLANCA"
.AddItem "92 - RESISTENCIA CHACO"
.AddItem "ACOYTE"
.AddItem "AGUIRRE"
.AddItem "ALDREY"
.AddItem "AUCHAN"
.AddItem "CABELLO"
.AddItem "CABILDO"
.AddItem "CANNING"
.AddItem "CORDOBA 2"
.AddItem "CORDOBA 3"
.AddItem "ELCANO"
.AddItem "FLORIDA"
.AddItem "GALLO"
.AddItem "LACROZE"
.AddItem "LIBERTADOR 2"
.AddItem "LOMAS CENTER"
.AddItem "MARTINEZ"
.AddItem "MEDRANO"
.AddItem "PILAR2"
.AddItem "PLAZA OESTE"
.AddItem "RAWSON"
.AddItem "RIOBAMBA"
.AddItem "RIVADAVIA"
.AddItem "ROSARIO MINETTI"
.AddItem "ROSARIO SHOPPING"
.AddItem "SANTA FE"
.AddItem "TALCAHUANO"
.TabIndex = 1
With ComboBox4
.AddItem "1"
.AddItem "2"
.AddItem "3"
.AddItem "4"
.AddItem "5"
.AddItem "6"
.TabIndex = 1
End With
End With
TextBox1.TabIndex = 2
End Sub
Private Sub CommandButton1_Click()
Set h = Sheets("REGISTROS") 'hoja a buscar
Set b = h.Range("A:A").Find(TextBox5.Text, lookat:=xlWhole)
If Not b Is Nothing Then
If MsgBox("VALOR ENCONTRADO ¿DESEA ELIMINARLO?", vbExclamation + vbYesNo, "AVISO") = vbYes Then
h.Rows(b.Row).Delete
End If
Else
MsgBox "VALOR NO ENCONTRADO"
End If
End Sub
Private Sub TextBox10_Change() 'APLICAR / A FECHA
largo_entrada = Len(Me.TextBox2)
Select Case largo_entrada
Case 2
Me.TextBox2.Value = Me.TextBox2.Value & "/"
Case 5
Me.TextBox2.Value = Me.TextBox2.Value & "/"
End Select
End Sub
Private Sub CommandButton2_Click()
MsgBox "Datos Registrados!", vbInformation, ""
Unload Me
Despachos.Show
End Sub
Private Sub CommandButton4_Click()
MsgBox "Cerrar?", vbInformation, ""
Unload Me
End Sub