Botones primero,anterior,siguiente y ultimo registro en excel
Tengo cuatro botones para moverme por mis registro de una hoja excel.
Los botones primero y ultimo van perfectos. Los botones anterior y siguiente van bien pero con un matiz.
Cuando llego con el boton anterior al primer registro y le doy despues a siguiente me salta un resgitro (me pasa del registro 1 al 3) y con el boton siguiente cuando llego al ultimo registro y le doy despues al boton anterior me salta un resgitro (del 15 al 13).
Coloco el codigo de los 4 botones a ver si me puede ayudar. GRACIAS!
CODIGO
Public fila
Private Sub cmb_anterior_Click()
Cells(fila - 1, 1).Select
cbx_codigo.Value = ActiveCell
txt_nombre.Value = ActiveCell.Offset(0, 1)
cbx_plataforma.Value = ActiveCell.Offset(0, 2)
cbx_consola.Value = ActiveCell.Offset(0, 3)
cbx_categoria.Value = ActiveCell.Offset(0, 4)
cbx_grupo.Value = ActiveCell.Offset(0, 5)
cbx_estado.Value = ActiveCell.Offset(0, 6)
cbx_condicion.Value = ActiveCell.Offset(0, 7)
txt_ubicacion.Value = ActiveCell.Offset(0, 8)
txt_precio.Value = ActiveCell.Offset(0, 9)
txt_cantidad.Value = ActiveCell.Offset(0, 10)
If ActiveCell.Row = 2 Then
MsgBox "Estás en el primer artículo", vbInformation, "MIS JUEGOS"
Exit Sub
End If
fila = ActiveCell.Row
End Sub
Private Sub cmb_primero_Click()
cbx_codigo.Value = Range("A2").Value
txt_nombre.Value = Range("B2").Value
cbx_plataforma.Value = Range("C2").Value
cbx_consola.Value = Range("D2").Value
cbx_categoria.Value = Range("E2").Value
cbx_grupo.Value = Range("F2").Value
cbx_estado.Value = Range("G2").Value
cbx_condicion.Value = Range("H2").Value
txt_ubicacion.Value = Range("I2").Value
txt_precio.Value = Range("J2").Value
txt_cantidad.Value = Range("K2").Value
fila = 2
MsgBox "Estás en el primer artículo", vbInformation, "MIS JUEGOS"
End Sub
Private Sub cmb_siguiente_Click()
ultima = Range("a65000").End(xlUp).Row
Cells(fila + 1, 1).Select
cbx_codigo.Value = ActiveCell
txt_nombre.Value = ActiveCell.Offset(0, 1)
cbx_plataforma.Value = ActiveCell.Offset(0, 2)
cbx_consola.Value = ActiveCell.Offset(0, 3)
cbx_categoria.Value = ActiveCell.Offset(0, 4)
cbx_grupo.Value = ActiveCell.Offset(0, 5)
cbx_estado.Value = ActiveCell.Offset(0, 6)
cbx_condicion.Value = ActiveCell.Offset(0, 7)
txt_ubicacion.Value = ActiveCell.Offset(0, 8)
txt_precio.Value = ActiveCell.Offset(0, 9)
txt_cantidad.Value = ActiveCell.Offset(0, 10)
If ActiveCell.Row = ultima Then
MsgBox "Estás en el último artículo", vbInformation, "MIS JUEGOS"
Exit Sub
End If
fila = ActiveCell.Row
End Sub
Private Sub cmb_ultimo_Click()
ultima = Range("a65000").End(xlUp).Row
Cells(ultima, 1).Select
cbx_codigo.Value = ActiveCell
txt_nombre.Value = ActiveCell.Offset(0, 1)
cbx_plataforma.Value = ActiveCell.Offset(0, 2)
cbx_consola.Value = ActiveCell.Offset(0, 3)
cbx_categoria.Value = ActiveCell.Offset(0, 4)
cbx_grupo.Value = ActiveCell.Offset(0, 5)
cbx_estado.Value = ActiveCell.Offset(0, 6)
cbx_condicion.Value = ActiveCell.Offset(0, 7)
txt_ubicacion.Value = ActiveCell.Offset(0, 8)
txt_precio.Value = ActiveCell.Offset(0, 9)
txt_cantidad.Value = ActiveCell.Offset(0, 10)
fila = ActiveCell.Row
MsgBox "Estás en el último artículo", vbInformation, "MIS JUEGOS"
End Sub