Botones Siguiente Anterior

Buenas tardes estoy iniciando con la programación en excel si me pudiesen colaborar con el siguiente problema:
Estoy programando el botón de Ultimo, anterior, siguiente, y ultimo registro y me muestre en un label el numero de registro con un contador, para esto estoy utilizando los siguientes comandos
Private Sub CmdPrimero_Click()
Sheets("Alumno").Select
Range("A2").Select
TxtRegistro.Text = 1
TxtAlumno.Text = ActiveCell
TxtNombres.Text = ActiveCell.Offset(0, 1)
TxtApellidos.Text = ActiveCell.Offset(0, 2)
TxtDireccion.Text = ActiveCell.Offset(0, 3)
TxtTelefono.Text = ActiveCell.Offset(0, 4)
CbEps.Text = ActiveCell.Offset(0, 5)
Cbcarrera.Text = ActiveCell.Offset(0, 6)
Cbdia.Text = ActiveCell.Offset(0, 7)
Cbmes.Text = ActiveCell.Offset(0, 7)
Cbaño.Text = ActiveCell.Offset(0, 7)
If ActiveCell.Offset(0, 8) = "Femenino" Then
    OpFemenino = True
End If
If ActiveCell.Offset(0, 8) = "Masculino" Then
    OpMasculino = True
End If
End Sub
Private Sub CmdUltimo_Click()
Sheets("Alumno").Select
cont = 1
Range("A2").Select
While (ActiveCell <> Empty)
    ActiveCell.Offset(1, 0).Select
    cont = cont + 1
Wend
ActiveCell.Offset(-1, 0).Select
TxtRegistro.Text = cont + 1
TxtAlumno.Text = ActiveCell
TxtNombres.Text = ActiveCell.Offset(0, 1)
TxtApellidos.Text = ActiveCell.Offset(0, 2)
TxtDireccion.Text = ActiveCell.Offset(0, 3)
TxtTelefono.Text = ActiveCell.Offset(0, 4)
CbEps.Text = ActiveCell.Offset(0, 5)
Cbcarrera.Text = ActiveCell.Offset(0, 6)
Cbdia.Text = ActiveCell.Offset(0, 7)
Cbmes.Text = ActiveCell.Offset(0, 7)
Cbaño.Text = ActiveCell.Offset(0, 7)
If ActiveCell.Offset(0, 8) = "Femenino" Then
    OpFemenino = True
End If
If ActiveCell.Offset(0, 8) = "Masculino" Then
    OpMasculino = True
End If
End Sub
Private Sub CmdSiguiente_Click()
Sheets("alumno").Select
r = Val(TxtRegistro.Text)
While (r > 1)
    ActiveCell.Offset(1, 0).Select
    r = r - 1
Wend
ActiveCell.Offset(1, 0).Select
TxtRegistro.Text = r
TxtAlumno.Text = ActiveCell
TxtNombres.Text = ActiveCell.Offset(0, 1)
TxtApellidos.Text = ActiveCell.Offset(0, 2)
TxtDireccion.Text = ActiveCell.Offset(0, 3)
TxtTelefono.Text = ActiveCell.Offset(0, 4)
CbEps.Text = ActiveCell.Offset(0, 5)
Cbcarrera.Text = ActiveCell.Offset(0, 6)
Cbdia.Text = ActiveCell.Offset(0, 7)
Cbmes.Text = ActiveCell.Offset(0, 7)
Cbaño.Text = ActiveCell.Offset(0, 7)
If ActiveCell.Offset(0, 8) = "Femenino" Then
    OpFemenino = True
End If
If ActiveCell.Offset(0, 8) = "Masculino" Then
    OpMasculino = True
End If
End Sub
Me gustaría me colaboraran para el anterior y el siguiente que no me están funcionando bien, gracias si me guían con esto!

1 respuesta

Respuesta
1
En mi página de descargas tengo un ejemplo para lo que necesitas.
Se llama Interactuando con userforms. Tenés que tomar el Userform2 (recordá que la lista no debe tener duplicados)
Si luego de que la adaptes a tu libro te presenta alguna dificultad, escribime nuevamente con el código resultante para tu form.
Mira Elsa gracias por contestarme tengo los ejemplos que me diste ya los había valorado con anterioridad pero estos también me arrojan errores, entonces estoy como un poco perdido
Maleck
Enviame entonces tu hoja con tu UF (y las rutinas que ya tenés) para que te las ajuste.
El correo está en mi sitio, no olvides indicarme tu alias y/o motivo de consulta

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas