Necesito que con los códigos no se repitan. En una hoja de excel desde un formulario de visual basic.

Do While ActiveCell.Value <> ""
If ActiveCell.Value = "" Then
ActiveCell.Value = TextBox1.Value
Exit Do
Else
If ActiveCell.Value = TextBox1.Value Then
MsgBox "CODIGO REPETIDO"
TextBox1.Value = Empty
TextBox1.SetFocus
Exit Do
End If
End If
ActiveCell.Offset(4, 2) = TextBox1
Loop

1 respuesta

Respuesta
1

[Hola 

deseas buscar si un código se repite en una columna ? 

Private Sub CommandButton1_Click()
'
'***Por Adriel Ortiz
'
    Set h = Sheets("Hoja1") ' nombre de la hoja
    '
        Set r = h.Columns("A")
        Set b = r.Find(TextBox1, lookat:=xlWhole)
        If Not b Is Nothing Then
            MsgBox "El código ya existe"
        Else
            MsgBox "No encontrado"
        End If
End Sub

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas