Buscar registro por nombre y por fecha de ingreso

Del registro por medio de su nombre y la fecha en la que ingreso, debido a que el mismo registro puede ingresar varias veces en el año, pero nunca en el mismo día. Necesito realizar lo mediante Visual Basic, ya que he hecho un formulario para poder hacerlo.

Solo he podido hacer el proceso buscando por nombre, pero me falta buscar por Fecha de ingreso.

Adjunto lo que tengo realizado:

__________________________________________________________________________________________________

Private Function filaExisteRegistro(CodigoRegistro As String, RangoConsulta As String) As Long

Dim NumeroFila As Long

With Registro.Range(RangoConsulta)
Set c = .Find(CodigoRegistro, LookAt:=xlWhole)
If Not c Is Nothing Then
NumeroFila = c.Row
End If
End With
filaExisteRegistro = NumeroFila

End Function
__________________________________________________________________________________________________

Sub BuscarPor()

Dim ultFila As Long
Dim rango As String
Dim filaRegistro As Long
Dim Nombre As String
Dim Apellido As String
Dim FechaIngreso As String
Dim Sexo As String
Dim Area As String
Dim Acciom As String
Dim Estado as string

ultFila = Range("B" & Rows.Count).End(xlUp).Row
rango = "B7:B50000" & ultFila
If Len(frmActualizar.txtNombre) = 0 Then
MsgBox "Por favor ingresar el Nombre de Registro"
Exit Sub
End If
filaRegistro = filaExisteRegistro(frmActualizar.txtNombre, rango)
If filaRegistro = 0 Then
MsgBox "El Registro no exite", 64, "No Existe"
Exit Sub
End If

Apellido = Registro.Cells(filaRegistro, 3)
FechaIngreso = Registro.Cells(filaRegistro, 4)
Sexo = Registro.Cells(filaRegistro, 5)
Area = Registro.Cells(filaRegistro, 6)
Accion = Registro.Cells(filaRegistro, 7)
Estado = Registro.Cells(filaRegistro, 8)
frmActualizar.txtApellido = Apellido
frmActualizar.txtFechaIngreso = FechaIngreso
frmActualizar.txtSexo = Sexo
frmActualizar.txtArea = Area
frmActualizar.txtAccion = Accion
frmActualizar.txtEstado = Estado

End Sub

1 respuesta

Respuesta
1

H o l a: Envíame tu archivo con el formulario para adaptar el código

Mi correo [email protected]

En el asunto del correo escribe tu nombre de usuario “roberto gatica” y el título de esta pregunta.

Estimado,

Envié el documento solicitado

Te anexo el código para buscar por nombre, apellido y fecha

Private Sub cmdBuscar_Click()
'Por.Dante Amor
    'Limpia
    txtSexo = ""
    txtArea = ""
    txtAccion = ""
    txtEstado = ""
    'Validaciones
    If txtNombre = "" Then
        MsgBox "Ingresa el nombre"
        txtNombre.SetFocus
        Exit Sub
    End If
    If txtApellido = "" Then
        MsgBox "Ingresa el apellido"
        txtApellido.SetFocus
        Exit Sub
    End If
    If txtFechaIngreso = "" Or Not IsDate(txtFechaIngreso) Then
        MsgBox "Ingresa fecha"
        txtFechaIngreso.SetFocus
        Exit Sub
    End If
    '
    fila = 0
    Set h = Sheets("REGISTRO")
    Set r = h.Columns("B")
    Set b = r.Find(txtNombre, lookat:=xlWhole)
    If Not b Is Nothing Then
        celda = b.Address
        Do
            'detalle
            If LCase(h.Cells(b.Row, "C")) = LCase(txtApellido) And _
               h.Cells(b.Row, "D") = CDate(txtFechaIngreso) Then
                fila = b.Row
                Exit Do
            End If
            Set b = r.FindNext(b)
        Loop While Not b Is Nothing And b.Address <> celda
    End If
    If fila > 0 Then
        txtSexo = h.Cells(fila, "E")
        txtArea = h.Cells(fila, "F")
        txtAccion = h.Cells(fila, "G")
        txtEstado = h.Cells(fila, "H")
    Else
        MsgBox "El Registro no exite", vbExclamation, "No Existe"
    End If
End Sub

'S aludos. Dante Amor. Recuerda valorar la respuesta. G racias

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas