Indicar diferencias entre dos columnas

Me gustaría preguntarte Dante Amor una nueva pregunta, me ayudaste anteriormente con una macro que me actualiza los datos de un almacén nuevo, con respecto al viejo, es la siguiente:

Sub ActualizarUnidades()
'Por.Dante Amor
    Set h1 = Sheets("Hoja1")
    Set h2 = Sheets("Hoja2")
    Set h3 = Sheets("Resultado")
    '
    h3.Range("A:C").Clear
    j = 2
    u = WorksheetFunction.Max(h1.Range("A" & Rows.Count).End(xlUp).Row, h1.Range("B" & Rows.Count).End(xlUp).Row)
    For i = 2 To u
        hoja = 1
        If h1.Cells(i, "B") <> "" Then
            Set b = h2.Columns("B").Find(h1.Cells(i, "B"), lookat:=xlWhole)
            If Not b Is Nothing Then hoja = 2
        Else
            Set b = h2.Columns("A").Find(h1.Cells(i, "A"), lookat:=xlWhole)
            If Not b Is Nothing Then hoja = 2
        End If
        '
        h3.Cells(j, "A") = h1.Cells(i, "A")
        h3.Cells(j, "B") = h1.Cells(i, "B")
        If hoja = 1 Then
            h3.Cells(j, "C") = h1.Cells(i, "C")
        Else
            h3.Cells(j, "C") = h2.Cells(b.Row, "C")
        End If
        j = j + 1
    Next
    MsgBox "Unidades Actualizadas", vbInformation
End Sub

y ahora me preguntaba si me podrías ayudar a modificarla para que, en vez de devolverme en la hoja 3 de "Resultado" los datos de la "Hoja1" actualizados con los nuevos datos de la "Hoja2", solo mostrara los datos actualizados, es decir, aquellos datos de la hoja 1 que no se modifiquen, que no se indiquen en la hoja de "Resultados".

1 Respuesta

Respuesta
1

 H o l  a :

Puedes enviarme el archivo explicando con ejemplos cuál es el resultado que quieres. Recuerda poner tu nombre de usuario en el asunto del correo.

Ya te envié el correo! 

Mil gracias :)

Anexo la macro

Sub ActualizarUnidades()
'Por.Dante Amor
    Set h1 = Sheets("Hoja1")
    Set h2 = Sheets("Hoja2")
    Set h3 = Sheets("Resultado")
    '
    u3 = h1.Range("A" & Rows.Count).End(xlUp).Row + 3
    h3.Range("A2:C" & u3).Clear
    j = 2
    u = WorksheetFunction.Max(h2.Range("A" & Rows.Count).End(xlUp).Row, h2.Range("B" & Rows.Count).End(xlUp).Row)
    For i = 2 To u
        existe = False
        If h2.Cells(i, "B") <> "" Then
            Set b = h1.Columns("B").Find(h2.Cells(i, "B"), lookat:=xlWhole)
            If Not b Is Nothing Then
                If h1.Cells(b.Row, "C") <> h2.Cells(i, "C") Then
                    h3.Cells(j, "A") = h1.Cells(b.Row, "A")
                    h3.Cells(j, "B") = h1.Cells(b.Row, "B")
                    h3.Cells(j, "C") = h2.Cells(i, "C")
                    j = j + 1
                End If
            Else
                Set b = h1.Columns("A").Find(h2.Cells(i, "A"), lookat:=xlWhole)
                If Not b Is Nothing Then
                    If h1.Cells(b.Row, "C") <> h2.Cells(i, "C") Then
                        h3.Cells(j, "A") = h1.Cells(b.Row, "A")
                        h3.Cells(j, "B") = h1.Cells(b.Row, "B")
                        h3.Cells(j, "C") = h2.Cells(i, "C")
                        j = j + 1
                    End If
                Else
'                    h3.Cells(j, "A") = h2.Cells(i, "A")
'                    h3.Cells(j, "B") = h2.Cells(i, "B")
'                    h3.Cells(j, "C") = h2.Cells(i, "C")
'                    j = j + 1
                End If
            End If
        Else
            Set b = h1.Columns("A").Find(h2.Cells(i, "A"), lookat:=xlWhole)
            If Not b Is Nothing Then
                If h1.Cells(b.Row, "C") <> h2.Cells(i, "C") Then
                    h3.Cells(j, "A") = h1.Cells(b.Row, "A")
                    h3.Cells(j, "B") = h1.Cells(b.Row, "B")
                    h3.Cells(j, "C") = h2.Cells(i, "C")
                    j = j + 1
                End If
            Else
'                h3.Cells(j, "A") = h2.Cells(i, "A")
'                h3.Cells(j, "B") = h2.Cells(i, "B")
'                h3.Cells(j, "C") = h2.Cells(i, "C")
'                j = j + 1
            End If
        End If
    Next
    MsgBox "Unidades Actualizadas", vbInformation
End Sub

sal u dos

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas