Está en la página 1de 1

Private Sub imgCerrar_Click()

Unload Me
End Sub
Private Sub imgGuardar_Click()
guardarInfo
End Sub
Sub guardarInfo()

'Declaracion de Variables
Dim contFila As Long
Dim hoja As Worksheet
Set hoja = Worksheets(2)
'Validacion de cajas de texto
If Trim$(cajaNombre.Text) = Empty Or Trim$(cajaApellidos.Text) = Empty Or Trim$(cajaDireccion.Text) = Empty Or Trim$(cajaTelefono.Text) = Empty Or Trim$(cajaCorreo.Text) = Empty Or
Trim$(cajaSexo.Text) = Empty Or Trim$(cajaCumpleaños.Text) = Empty Then
MsgBox "Todos los campos son obligatorios!!!", vbCritical, "Datos Incompletos"
Exit Sub
End If
'validamos la fila siguiente en la hoja en donde se deben ingresar los datos
contFila = hoja.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

hoja.Cells(contFila, 1).Value = Me.cajaNombre.Value


hoja.Cells(contFila, 2).Value = Me.cajaApellidos.Value
hoja.Cells(contFila, 3).Value = Me.cajaDireccion.Value
hoja.Cells(contFila, 4).Value = Me.cajaTelefono.Value
hoja.Cells(contFila, 5).Value = Me.cajaCorreo.Value
hoja.Cells(contFila, 6).Value = Me.cajaSexo.Value
hoja.Cells(contFila, 7).Value = Me.cajaCumpleaños.Value

'limpiamos las cajas de texto posicioamos en el primer campo


Me.cajaNombre.Value = ""
Me.cajaApellidos.Value = ""
Me.cajaDireccion.Value = ""
Me.cajaTelefono.Value = ""
Me.cajaCorreo.Value = ""
Me.cajaSexo.Value = ""
Me.cajaCumpleaños.Value = ""

Me.cajaNombre.SetFocus
End Sub

También podría gustarte