Buscar un registro en la columna "F"
Tengo un código que me gustaría reducir de tamaño lo que se pueda, y que antes de registrar, busque si el valor existe en la columna "F".
Private Sub btn_Registrar_Click()
'Dim fila As Integer
'Dim final As Integer
'Dim Registro As Integer
'Dim nDoc As String
'
'Hoja6.Visible = xlSheetVisible
'Hoja6.Select
'
' For fila = 1 To 2000
' If Hoja6.Cells(fila, 1) = "" Then
' final = fila
' Exit For
' End If
' Next
'
' For Registro = 2 To final
' If Hoja6.Cells(Registro, 1) = Me.Txt_NIF Then
' Me.Txt_NIF.BackColor = &H8080FF
' MsgBox ("El cliente introducido ya está registrado")
' Me.Txt_NombreApellido.SetFocus
' Exit Sub
' Exit For
' End If
' Next
' nDoc = Application.InputBox("Ingrese el Tipo de Documento")
'
' If MsgBox("Son correctos los datos?", vbOKCancel) = vbOK Then
' 'Me.Txt_NIF.BackColor = &HE0E0E0
' Hoja6.Cells(final, 1) = nDoc & "-" & Me.Txt_NIF.Text
' Hoja6.Cells(final, 2) = Me.Txt_NombreApellido.Text
' Hoja6.Cells(final, 3) = Me.Txt_Direccion.Text
' Hoja6.Cells(final, 4) = Me.Txt_Provincia.Text
' Hoja6.Cells(final, 5) = Me.Txt_CodigoPos.Text
' Hoja6.Cells(final, 6) = Me.Txt_Telefono.Text
'
' Me.Txt_NIF = ""
' Me.Txt_NombreApellido = ""
' Me.Txt_CodigoPos = ""
' Me.Txt_Direccion = ""
' Me.Txt_Provincia = ""
' Me.Txt_Telefono = ""
' Me.Txt_NombreApellido.SetFocus
' Else
' Exit Sub
' End If
' Hoja6.Visible = xlSheetVeryHidden
End Sub
1 respuesta
Respuesta de Dante Amor
2

