Sub Borders()
Dim i As Long
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
Application.ScreenUpdating = False
For i = 2 To ws.Range("A" & Rows.Count).End(xlUp).Row
'Top Border
If ws.Range("A" & i).Value <> ws.Range("A" & i - 1).Value Then
With ws.Range("A" & i & ":F" & i).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.Color = vbBlack
End With
'Left Border
With ws.Range("A" & i).Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.Color = vbBlack
End With
'Right Border
With ws.Range("F" & i).Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.Color = vbBlack
End With
End If
'Bottom Border
If ws.Range("A" & i).Value <> ws.Range("A" & i + 1).Value Then
With ws.Range("A" & i & ":F" & i).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.Color = vbBlack
End With
'Left Border
With ws.Range("A" & i).Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.Color = vbBlack
End With
'Right Border
With ws.Range("F" & i).Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.Color = vbBlack
End With
End If
'Middle Borders
If ws.Range("A" & i).Value = ws.Range("A" & i + 1).Value And ws.Range("A" & i).Value = ws.Range("A" & i - 1).Value Then
'Left Border
With ws.Range("A" & i).Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.Color = vbBlack
End With
'Right Border
With ws.Range("F" & i).Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.Color = vbBlack
End With
End If
If ws.Range("C" & i).Value > 1 Then
ws.Range("C" & i).Interior.Color = vbYellow
End If
If InStr(1, ws.Range("E" & i).Value, "IOSS", vbTextCompare) Or InStr(1, ws.Range("E" & i).Value, "GIFT", vbTextCompare) Then
ws.Range("E" & i).Interior.Color = vbYellow
End If
Next
Application.ScreenUpdating = True
End Sub