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:

Excel VBA, Borders Remove

Jump To:

 


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:

Excel VBA, Borders Remove, Left Edge


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:

Excel VBA, Borders Remove, Top Edge


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:

Excel VBA, Borders Remove, Right Edge


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:

Excel VBA, Borders Remove Bottom Edge


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:

Excel VBA, Borders Remove, Inside Vertical Edge


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:

Excel VBA, Borders Remove, Inside Horizontal Edge


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:

Excel VBA, Borders Remove Diagonal up


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:

Excel VBA, Borders Remove Diagonal Down

See also:

 

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”

Leave a Reply

Your email address will not be published. Required fields are marked *