MACRO con EVENTO que compara 2 columnas con datos "alfanumericos"y da comentario en col."Resultado"

Te pido realices la modificación a la PRIMERA MACRO que me enviaste para que funcione con datos "alfanumericos" (combinación de letras y números). El trabajo que haría la macro seria comparar 2 columnas y si los dos datos alfanuméricos coinciden se pondrá en la columna resultado la palabra "ok" y si los datos son diferentes se pondrá la palabra "REVISAR".

Abajo esta tu MACRO

'compara dos columnas y muestra comentario en columna "resultado"
'ESCRITO POR DANTE AMOR 4 NOV 2015
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Row < 5 Then Exit Sub
    If Target.Count > 5 Then Exit Sub
    Cells.Interior.ColorIndex = 0
    If Not Intersect(Target, Columns("B")) Is Nothing Then
        Target.EntireRow.Interior.ColorIndex = 42
        If Cells(Target.Row, "D") = "" Or Cells(Target.Row, "E") = "" Then Exit Sub
        If Cells(Target.Row, "D") - Cells(Target.Row, "E") = 0 Then
            With Cells(Target.Row, "F")
                .Value = "ok"
                .Font.ColorIndex = 3
                .Font.Size = 14
            End With
        Else
            With Cells(Target.Row, "F")
                .Value = "CAMBIAR"
                .Font.ColorIndex = xlAutomatic
                .Font.Size = 11
            End With
        End If
    End If
End Sub

1 respuesta

Respuesta
1

H o l a:

Supongo que las columnas a comparar son las mismas: D y E; y en la columna F el resultado:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Por.Dante Amor
    If Target.Row < 5 Then Exit Sub
    If Target.Count > 5 Then Exit Sub
    Cells.Interior.ColorIndex = 0
    If Not Intersect(Target, Columns("B")) Is Nothing Then
        Target.EntireRow.Interior.ColorIndex = 42
        If Cells(Target.Row, "D") = "" Or Cells(Target.Row, "E") = "" Then Exit Sub
        If Cells(Target.Row, "D") = Cells(Target.Row, "E") Then
            With Cells(Target.Row, "F")
                .Value = "ok"
                .Font.ColorIndex = 3
                .Font.Size = 14
            End With
        Else
            With Cells(Target.Row, "F")
                .Value = "CAMBIAR"
                .Font.ColorIndex = xlAutomatic
                .Font.Size = 11
            End With
        End If
    End If
End Sub

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas