Excel VBA, Remove Border
In this article I will explain how you can remove borders from a range of cells. Removing borders is similar to creating borders. All you have to do is set the .LineStyle property to xlNone. For more information about creating borders please see Excel VBA, Create Border.
In this article I will assume we have the following borders in the range B2:H11. Each section will explain how you can remove the border from one of the edges:
Jump To:
- Remove Border, Left Edge
- Remove Border, Top Edge
- Remove Border, Right Edge
- Remove Border, Bottom Edge
- Remove Border, Inside Vertical
- Remove Border, Inside Horizontal
- Remove Border, Diagonal Up
- Remove Border, Diagonal Down
Contents
Remove Border, Left Edge:
The code below will remove the borders from the left edge of the range B2:H11:
Range("B2:H11").Borders(xlEdgeLeft).LineStyle = xlNone
The line below is also equivilant to the previous line:
Range(Cells(2, 2), Cells(8, 11)).Borders(xlEdgeLeft).LineStyle _
= xlNone
Result:
Remove Border, Top Edge:
The code below will remove the borders from the top edge of the range B2:H11:
Range("B2:H11").Borders(xlEdgeTop).LineStyle = xlNone
The line below is also equivilant to the previous line:
Range(Cells(2, 2), Cells(8, 11)).Borders(xlEdgeTop).LineStyle _
= xlNone
Result:
Remove Border, Right Edge:
The code below will remove the borders from the right edge of the range B2:H11:
Range("B2:H11").Borders(xlEdgeRight).LineStyle = xlNone
The line below is also equivilant to the previous line:
Range(Cells(2, 2), Cells(8, 11)).Borders(xlEdgeRight).LineStyle _
= xlNone
Result:
Remove Border, Bottom Edge:
The code below will remove the borders from the bottom edge of the range B2:H11:
Range("B2:H11").Borders(xlEdgeBottom).LineStyle = xlNone
The line below is also equivilant to the previous line:
Range(Cells(2, 2), Cells(8, 11)).Borders(xlEdgeBottom).LineStyle _
= xlNone
Result:
Remove Border, Inside Vertical:
The code below will remove the vertical borders from the inside part of the range B2:H11:
Range("B2:H11").Borders(xlInsideVertical).LineStyle = xlNone
The line below is also equivilant to the previous line:
Range(Cells(2, 2), Cells(8, 11)).Borders(xlInsideVertical).LineStyle _
= xlNone
Result:
Remove Border, Inside Horizontal:
The code below will remove the horizontal borders from the inside part of the range B2:H11:
Range("B2:H11").Borders(xlInsideHorizontal).LineStyle = xlNone
The line below is also equivilant to the previous line:
Range(Cells(2, 2), Cells(8, 11)).Borders(xlInsideHorizontal).LineStyle _
= xlNone
Result:
Remove Border, Diagonal Up:
The code below will remove the diagonal up borders from the inside part of the range B2:H11:
Range("B2:H11").Borders(xlDiagonalUp).LineStyle = xlNone
The line below is also equivilant to the previous line:
Range(Cells(2, 2), Cells(8, 11)).Borders(xlDiagonalUp).LineStyle _
= xlNone
Result:
Remove Border, Diagonal Down:
The code below will remove the diagonal down borders from the inside part of the range B2:H11:
Range("B2:H11").Borders(xlDiagonalDown).LineStyle = xlNone
The line below is also equivilant to the previous line:
Range(Cells(2, 2), Cells(8, 11)).Borders(xlDiagonalDown).LineStyle _
= xlNone
Result:
See also:
- Excel VBA, Create Border
- Excel VBA, Format Cells and Ranges Using the Macro Recorder
- Excel VBA Border Colors
- Excel VBA, Border Style and Thickness
- Excel VBA, Get Border Properties
- Excel VBA Borders
If you need assistance with your code, or you are looking for a VBA programmer to hire feel free to contact me. Also please visit my website www.software-solutions-online.com
One thought on “Excel VBA, Remove Border”