Show Grid on Colored Range (Apply Border)

Whenever we apply background color to a range in Excel, we lost our gridlines. This macro, which is just a trick by applying colored border to the range will make it different i.e. Colored Range with Grid Lines. For eg. see the image below:






Sub Show_Grid_on_Color_Range()
   With Selection
      Selection.BorderAround xlContinuous, xlThin, , RGB(192, 192, 192)
      If .Columns.Count> 1 Then
         With .Borders(xlInsideVertical)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .Color = RGB(192, 192, 192)
         End With
      End If
      If
.Rows.Count> 1 Then
         With
.Borders(xlInsideHorizontal)
            .LineStyle = xlContinuous
            .Weight = xlThin
            .Color = RGB(192, 192, 192)
         End With
      End If
   End With
End Sub




Comments