Tuesday, March 30, 2010

Draw Border for the common cell values



Sub Draw_border_for_common_items_in_row()

Sheets("Sheet1").Select
LC1 = ActiveSheet.UsedRange.SpecialCells(xlLastCell).Column
LR1 = ActiveSheet.UsedRange.SpecialCells(xlLastCell).Row

For i = 1 To LC1
temp = Cells(2, i).Value
ro = 2
    For j = 2 To LR1
        If Cells(j, i).Value <> temp Then
            Range(Cells(ro, i), Cells(j - 1, i)).Select
            Selection.BorderAround Weight:=xlThin
            ro = j
            temp = Cells(j, i).Value           
        End If       
    Next j
Next i

End Sub

No comments:

Post a Comment