Quisiera buscar un valor (nombre) en una BD de excel y poder modificar algún valor "" ubicado en su misma fila y reemplazarlo


Quisiera buscar un valor por ejemplo un "nombre" en una base de datos de excel si es posible "ubicarlo en una lista desplegable" y al seleccionarlo poder ingresar un dato ubicado en su misma fila que al llenarlo en otra celda y luego activar el botón se inserte el dato que coloqué donde corresponda.
Agradezco de antemano su gentil ayuda.

1 Respuesta

Respuesta
1
Sub Pegar()
    Set h = ActiveSheet
    'validaciones
    If h.ComboBox1.Value = "" Then
        MsgBox "Falta el artículo", vbExclamation
        Exit Sub
    End If
    If h.ComboBox2.Value = "" Then
        MsgBox "Falta la talla", vbExclamation
        Exit Sub
    End If
    If h.ComboBox3.Value = "" Then
        MsgBox "Falta el color", vbExclamation
        Exit Sub
    End If
    fecha = h.Range("B2").Value
    If fecha = "" Or Not IsDate(fecha) Then
        MsgBox "Falta la fecha", vbExclamation
        Exit Sub
    End If
    Set b = h.Rows(4).Find(fecha, lookat:=xlWhole)
        If Not b Is Nothing Then
            col = b.Column
        Else
            MsgBox "No existe la fecha", vbCritical
            Exit Sub
        End If
    Set b = Nothing
    '
    valor = h.Range("C2").Value
    If valor = "" Or Not IsNumeric(valor) Then
        MsgBox "Falta el valor de producción"
        Exit Sub
    End If
    '
    'Busca
    existe_art = False
    Set r = h.Columns("A")
    Set b = r.Find(h.ComboBox1.Value, lookat:=xlWhole)
    If Not b Is Nothing Then
        celda = b.Address
        Do
            'detalle
            If LCase(h.Cells(b.Row, "B").Value) = LCase(h.ComboBox2.Value) And _
               LCase(h.Cells(b.Row, "C").Value) = LCase(h.ComboBox3.Value) Then
               existe_art = True
               fila = b.Row
               h.Cells(fila, col) = valor
               MsgBox "Valor actualizado", vbInformation
               Exit Do
            End If
            Set b = r.FindNext(b)
        Loop While Not b Is Nothing And b.Address <> celda
    End If
    If existe_art = False Then
        MsgBox "No existe el artículo", vbCritical
    End If
End Sub

Ésta macro puede ser muy útil.

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas