Friday, April 13, 2012

Excel compare columns

Sub Compare2Cols()

' Principals

' For x = 1 To 32 Step 4

' For y = 2 To 106

' Cost Centers

' For x = 1 To 83 Step 4

' For y = 2 To 78

' Levels

' For x = 5 To 8 Step 2

' For y = 2 To 32

For x = 5 To 8 Step 2

For y = 2 To 32

'For show ...

Cells(y, x).Select

If Cells(y, x) <> Cells(y, x + 1) Then

With Cells(y, x).Interior

.Pattern = xlSolid

.PatternColorIndex = xlAutomatic

.Color = 65535

.TintAndShade = 0

.PatternTintAndShade = 0

End With

With Cells(y, x + 1).Interior

.Pattern = xlSolid

.PatternColorIndex = xlAutomatic

.Color = 65535

.TintAndShade = 0

.PatternTintAndShade = 0

End With

Else

With Cells(y, x).Interior

.Pattern = xlNone

.TintAndShade = 0

.PatternTintAndShade = 0

End With

With Cells(y, x + 1).Interior

.Pattern = xlNone

.TintAndShade = 0

.PatternTintAndShade = 0

End With

End If

Next y

Next x

Cells(y, x).Select

End Sub

No comments: