RECUPERACIÓN SEGUNDO PERIODO
TUTORIALES
TUTORIAL 6
Dim fila As Long
Dim duplicados As Boolean
'Obtener la
fila disponible
fila =
Application.WorksheetFunction.CountA(Range("A:A")) + 1
duplicados
= False
'Validar si
se han ingresado datos duplicados
For i = 1 To fila
If Cells(i,
1).Value = UserForm1.TextBox1.Value Then
If Cells(i,
2).Value = UserForm1.TextBox2.Value Then
If
Cells(i, 3).Value = UserForm1.TextBox3.Value Then
'Se encontraron datos duplicados
MsgBox "Datos duplicados
en la fila " & i
duplicados = True
End If
End If
End If
Next i
If Not duplicados Then
'Insertar datos
capturados
Cells(fila,
1).Value = UserForm1.TextBox1.Value
Cells(fila,
2).Value = UserForm1.TextBox2.Value
Cells(fila,
3).Value = UserForm1.TextBox3.Value
'Limpiar cajas de texto
UserForm1.TextBox1.Value = ""
UserForm1.TextBox2.Value =
""
UserForm1.TextBox3.Value = ""
'Notificar al usuario
MsgBox "Datos insertados en la fila
" & fila
End If
BOTON CANCELAR
Unload me
Boton abrir formulario
Userform1.show
If Trim(TxtUser.Text) = "" Then
MsgBox "Ingrese Usuario", vbExclamation, "Alerta"
TxtUser.SetFocus
Exit Sub
End If
If Trim(TxtPass.Text) = "" Then
MsgBox "Ingrese Contraseña", vbExclamation, "Alerta"
TxtPass.SetFocus
Exit Sub
End If
If Trim(TxtUser.Text) = "COORD" And Trim(TxtPass.Text) = "1234" Then
MsgBox "Ingreso Permitido", vbInformation, "OK"
Application.Visible = True
End
Else
MsgBox "Los datos ingresados no son correctos, inténtelo de nuevo", vbExclamation, "Alerta"
End If
En ThisWorkbook
Hacemos doble clic y digitamos el siguiente código
Application.Visible = False
UserForm3.Show
CODIGO GUARDAR Y SALIR
ThisWorkbook.Close Savechanges = False
CODIGOS FORMULARIO DE INGRESO DE
PRODUCTOS
IR A BASES DE DATOS
Sheets("BASE DE DATOS").Select
BOTON CANCELAR
Unload Me
CODIGO GRABAR
ActiveWorkbook.save
BOTON CANCELAR
Unload Me
CODIGO GRABAR
ActiveWorkbook.save
CODIGO REGISTRAR PRODUCTOS
For I = 1 To 100
If Cells(I + 1, 2).Value = "" Then
Cells(I + 1, 2).Value = TextBox1.Text
Cells(I + 1, 3).Value = TextBox2.Text
Cells(I + 1, 4).Value = TextBox3.Text
Exit For
End If
Next
CODIGO LIMPIAR
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
BOTÓN INGRESAR
UserForm3.Show
VÍDEO TUTORIAL 1