Una macro que me busque un valor y como de resultado me de los valores de esa fila?

Que tal buena tarde necesito una macro que me busque en una hoja que tiene una base de datos, un valor y como de resultado me de los valores de esa fila o de los datos que esten la derecha y estos resultados me los arroje en un rango de celdas de otra hoja.

1 respuesta

Respuesta
2

¿Esta pregunta es sobre el mismo tema del archivo que me enviaste?

Si es así, envíame un ejemplo claro y te preparo la macro.

Saludos. Dante Amor

Te anexo la macro para obtener los datos de la fila

Sub TraerDatos()
'Por.Dante Amor
    Set h1 = Sheets("Hoja4")
    Set h2 = Sheets("Respaldo1")
    '
    i = 10
    Do While Cells(i, "B") <> "" Or Cells(i + 1, "B") <> ""
        i = i + 2
    Loop
    '
    Set b = h2.Columns("B").Find(h1.[T3], lookat:=xlWhole, LookIn:=xlValues)
    If Not b Is Nothing Then
        h1.Cells(i, "B") = h2.Cells(b.Row, "C")     'Orden de compra
        h1.Cells(i, "C") = h2.Cells(b.Row, "D")     'Cons
        h1.Cells(i, "D") = h2.Cells(b.Row, "E")     'Rda
        h1.Cells(i, "E") = h2.Cells(b.Row, "F")     'Ent
        h1.Cells(i + 1, "I") = h2.Cells(b.Row, "G") 'cantidad
        'h1.Cells(i+1, "J") = h2.Cells(b.Row, "C")  'unidad
        h1.Cells(i + 1, "L") = h2.Cells(b.Row, "H") 'Fecha
        h1.Cells(i + 1, "N") = h2.Cells(b.Row, "I") 'Precio
        h1.Cells(i, "P") = h2.Cells(b.Row, "J")     'Factura
        h1.Cells(i, "Q") = h2.Cells(b.Row, "K")     'Lote
    Else
        MsgBox "Número de folio no existe", vbExclamation
    End If
End Sub
Sub TraerDatos2()
'Por.Dante Amor
    Set h1 = Sheets("Hoja4")
    Set h2 = Sheets("Respaldo1")
    h1.Unprotect "abc"
    '
    i = 10
    Do While Cells(i, "B") <> "" Or Cells(i + 1, "B") <> ""
        i = i + 2
    Loop
    '
    Set b = h2.Columns("B").Find(h1.[T3], lookat:=xlWhole, LookIn:=xlValues)
    If Not b Is Nothing Then
        h1.Cells(i, "B") = h2.Cells(b.Row, "C")     'Orden de compra
        h1.Cells(i, "C") = h2.Cells(b.Row, "D")     'Cons
        h1.Cells(i, "D") = h2.Cells(b.Row, "E")     'Rda
        h1.Cells(i, "E") = h2.Cells(b.Row, "F")     'Ent
        h1.Cells(i + 1, "I") = h2.Cells(b.Row, "G") 'cantidad
        'h1.Cells(i+1, "J") = h2.Cells(b.Row, "C")  'unidad
        h1.Cells(i + 1, "L") = h2.Cells(b.Row, "H") 'Fecha
        h1.Cells(i + 1, "N") = h2.Cells(b.Row, "I") 'Precio
        h1.Cells(i, "P") = h2.Cells(b.Row, "J")     'Factura
        h1.Cells(i, "Q") = h2.Cells(b.Row, "K")     'Lote
    Else
        MsgBox "Número de folio no existe", vbExclamation
    End If
    h1.Protect "abc"
End Sub

Saludos.Dante Amor

¡Gracias! 

Era eso lo que esperaba maestro.

Hola buen día tengo unas preguntillas con respecto a las macros de arriba, ya quedo bien eso que quería:

1-¿Cual de las dos macros utilizo o es igual?

2-¿ Ahora ya que tenemos la información de las celdas verdes reflejadas y visualizadas, tendrías una macro que al momento de capturar la información que falta que seria la de las celdas en amarillo se valla o se vallan a la fila o filas del folio buscado.? seria lo ultimo te lo agradecería. 

La primera es por si tu hoja no está protegida.

Utiliza la segunda se tu hoja está protegida.

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas