Skip to content

Instantly share code, notes, and snippets.

@Zadigo
Created October 25, 2017 18:08
Show Gist options
  • Save Zadigo/d938e75ee24960e3d4ed8202c8e12d86 to your computer and use it in GitHub Desktop.
Save Zadigo/d938e75ee24960e3d4ed8202c8e12d86 to your computer and use it in GitHub Desktop.
Create table borders anywhere in Excel
Sub create_Table_BordersAnywhere()
'Get current range selected
Dim current_Selection As Range
Set current_Selection = Selection
'Set in range
Dim create_Table As Range
Set create_Table = Range(current_Selection.Address)
Dim elements(5) As String
elements(0) = xlEdgeBottom
elements(1) = xlEdgeTop
elements(2) = xlEdgeLeft
elements(3) = xlEdgeRight
elements(4) = xlInsideHorizontal
elements(5) = xlInsideVertical
For Each w In elements
j.Cells.Borders(w).LineStyle = xlContinuous
j.Cells.Borders(w).Weight = xlThin
If w = xlEdgeTop Or w = xlEdgeBottom Or w = xlEdgeLeft Or w = xlEdgeRight Then
j.Cells.Borders(w).Weight = xlMedium
End If
Next
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment