Sub everyNcol()
'------------------ BEGIN - USER MODIFIABLE SECTION ------------------
c_step = 4 ' the number of cols between the enhanced col borders
thick_left = True
thick_right = True
'------------------ END - USER MODIFIABLE SECTION --------------------
Dim a As Range
Set a = Selection ' save current selection
If a.Cells.Count = a.EntireRow.Cells.Count Then
MsgBox "Please select entire columns or a finite range of cells" & _
" rather than of entire rows."
Exit Sub
End If
c_header = a.Column - 1 ' a header column would be prior to first column of selection
Application.ScreenUpdating = False ' False for faster macro
' Enhance the left-most border of the selection
With a.Borders(xlEdgeLeft)
'.LineStyle = xlContinuous
'.ColorIndex = xlAutomatic
If thick_left Then
.Weight = xlMedium
Else
.Weight = xlThin
End If
End With
' Turn off all inside vertical borders
With Selection.Borders(xlInsideVertical)
.LineStyle = xlNone
'.LineStyle = xlContinuous
'.ColorIndex = 15
End With
For Each c In a.Columns
If (c.Column - c_header) Mod c_step = 0 Then
c.Select ' doesn't work well when cells are merged accross columns
Selection.Borders(xlEdgeRight).Weight = xlThin
End If
Next
With a.Borders(xlEdgeRight)
'.LineStyle = xlContinuous
'.ColorIndex = xlAutomatic
If thick_right Then
.Weight = xlMedium
Else
.Weight = xlThin
End If
End With
Application.ScreenUpdating = True ' Restore setting
' Restore original selection
a.Select
End Sub