Jump to content

Comparar caracteres de las celdas


Recommended Posts

Hola:

Click en la primera celda, luego Ctrl+Click en la segunda celda, y ejecuta esta macro:

Sub PintarDiferencias()
For x = 1 To Len(Selection.Areas(1).Cells)
If Mid(Selection.Areas(1).Cells, x, 1) <> _
Mid(Selection.Areas(2).Cells, x, 1) Then
Selection.Areas(2).Cells.Characters(x).Font.Color = vbRed
End If
Next
End Sub[/CODE]

Saludos

Link to comment
Share on other sites

Hola:

El problema viene porqué interpreté que el texto de las celdas serían de la misma longitud.

Recuerda que la segunda celda la tienes que seleccionar con Ctrl+Click, si no te dará error.

Ahora ya funciona


Sub Botón2_Haga_clic_en()
l = Len(Selection.Areas(1).Cells)
If l < Len(Selection.Areas(2).Cells) Then
l = Len(Selection.Areas(2).Cells)
End If
For X = 1 To l
If Mid(Selection.Areas(1).Cells, X, 1) <> _
Mid(Selection.Areas(2).Cells, X, 1) Then
Selection.Areas(2).Cells.Characters(X).Font.Color = vbRed
End If
Next
End Sub


[/CODE]

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

Privacy Policy