View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
laralea laralea is offline
external usenet poster
 
Posts: 12
Default Filter or sort a macro result

The macro highlights cells and the user wants to sort or filter on the
highlighted rows so they can be deleted. Here's the macro.

Sub finddiff()
Application.ScreenUpdating = False

Range("A2", Range("b6900").End(xlUp)).ClearFormats

For Each x In Range("a2", Range("a6900").End(xlUp))
For Each y In Range("b2", Range("b6900").End(xlUp))
If x.Value = y.Value Then z = 1
Next
If z < 1 Then x.Interior.ColorIndex = 6
z = 0
Next

For Each s In Range("b2", Range("b6900").End(xlUp))

For Each t In Range("a2", Range("a6900").End(xlUp))
If s.Value = t.Value Then v = 1
Next
If v < 1 Then s.Interior.ColorIndex = 6
v = 0
Next

End Sub