Una vez efectuada búsqueda, si faltan datos añadir por textbox
Hola de nuevo, tengo otra duda, haber si me hacías el favor de resolvérmela, porque yo no doy con ello.
Tengo el siguiente código en un formulario de búsqueda de datos
Dim Dato As String, HayDatos As Boolean
Private Sub UserForm1_Initialize()
Sheets("ENTREGA LLAVES").Activate
CommandButton1.Caption = "Buscar Registro"
CommandButton2.Caption = "Siguiente"
CommandButton3.Caption = "Anterior"
End Sub
Private Sub TXTNºLLAVE_Enter()
CommandButton1.Caption = "Buscar Registro"
CommandButton1.Enabled = False
CommandButton2.Enabled = False
CommandButton3.Enabled = False
End Sub
Private Sub TXTNºLLAVE_Change()
CommandButton1.Enabled = True
End Sub
Private Sub CommandButton1_Click()
Range("A1").Select
Dato = TXTNºLLAVE
If Dato = "" Then Exit Sub
HayDatos = False
BuscarSiguiente
If HayDatos = True Then
CommandButton1.Caption = "Buscar desde el Inicio"
CommandButton2.Enabled = True
CommandButton3.Enabled = True
CommandButton2.SetFocus
End If
End Sub
Private Sub CommandButton2_Click() 'Buscar Siguiente
HayDatos = False
BuscarSiguiente
End Sub
Private Sub CommandButton3_Click() 'Buscar Anterior
HayDatos = False
BuscarAnterior
End Sub
Sub BuscarSiguiente()
Do While ActiveCell <> ""
ActiveCell.Offset(1, 0).Select
If ActiveCell = Dato Then
DatosEncontrados
HayDatos = True
CommandButton1.Enabled = True
CommandButton2.Enabled = True
Exit Do
End If
Loop
If HayDatos = False Then
If CommandButton3.Enabled = False Then
MsgBox "NO HAY MAS DATOS DE ESTA LLAVE", vbOKOnly, "Info"
TXTNºLLAVE = ""
CommandButton1.Enabled = False
Else
MsgBox "NO HAY DATOS DE ESTA LLAVE", vbOKOnly, "Info"
End If
End If
End Sub
Sub BuscarAnterior()
Do While ActiveCell <> Range("A1")
ActiveCell.Offset(-1, 0).Select
If ActiveCell = Dato Then
DatosEncontrados
HayDatos = True
Exit Do
End If
Loop
If HayDatos = False Then MsgBox "NO HAY MAS DATOS DE ESTA LLAVE", vbOKOnly, "Info"
End Sub
Sub DatosEncontrados()
TXTDEPENDENCIA.Text = ActiveCell.Offset(0, 1)
TXTIDENTIFICACION.Text = ActiveCell.Offset(0, 2)
TXTDESTINO.Text = ActiveCell.Offset(0, 3)
TXTFECHAENTREGA.Text = ActiveCell.Offset(0, 4)
TXTHORAENTREGA.Text = ActiveCell.Offset(0, 5)
TXTHORADEVOLUCION.Text = ActiveCell.Offset(0, 7)
Todo esto me sirve para buscar los datos que hay en una hoja, pero en ocasiones hay alguna celda que se tiene que rellanar con posterioridad, en este caso la que corresponderia al TextBox(TXTHORADEVOLUCION) y quisiera un código, que una vez encontrado el registro correspondiente con el boton siguiente, mediante el mismo textbox ingresara los datos y quedaran grabados en su sitio.
Muchas gracias de antemano. Un saludo Javi y Felices Fiestas