Created
October 25, 2017 18:08
-
-
Save Zadigo/d938e75ee24960e3d4ed8202c8e12d86 to your computer and use it in GitHub Desktop.
Create table borders anywhere in Excel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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