Macro para BUSCAR datos bajo 3 condiciones

Buenod días, dan me ha ayudado con este código el cual funciona ala perfección, pero a la hora de utilizarlo me sale un problema más el cual no tome encuenta

Las área de trabajo, en este caso fue un error que no contemple

Por ejemplo

DÍA: J

TURNO: M

ÁREA: PRODUCCIÓN (ESTE ES EL QUE NO CONSIDERE) que debe estar en celda K7

este es el codigo que me realizo dan

Sub Nombres()
'Por Dante Amor
    dia = Range("K8").Value
    Set b = Range("C8:G8").Find(dia, lookat:=xlWhole)
    If Not b Is Nothing Then
        col = b.Column
    Else
        MsgBox "No existe el día"
        Exit Sub
    End If
    '
    turno = Range("K9").Value
    AREA = Range("K7").Value
    fila = 10
    Range("J10:J" & Rows.Count).ClearContents
    For i = 10 To Range("B" & Rows.Count).End(xlUp).Row
        If Cells(i, col).Value = turno Then
            Cells(fila, "J") = Cells(i, "B")
            fila = fila + 1
        End If
    Next
End Sub

quisiera agregarle la 3era opcion de busqueda .

1 respuesta

Respuesta
2

Va

Sub Nombres()
'Por Dante Amor
    dia = Range("K8").Value
    Set b = Range("C8:G8").Find(dia, lookat:=xlWhole)
    If Not b Is Nothing Then
        col = b.Column
    Else
        MsgBox "No existe el día"
        Exit Sub
    End If
    '
    turno = Range("K9").Value
    AREA = Range("K7").Value
    fila = 10
    Range("J10:J" & Rows.Count).ClearContents
    For i = 10 To Range("B" & Rows.Count).End(xlUp).Row
        If Cells(i, col).Value = turno and cells(i, "C").value = AREA Then
            Cells(fila, "J") = Cells(i, "B")
            fila = fila + 1
        End If
    Next
End Sub

sal u dos

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas