How to add borders automatically to cells in Excel?

In Excel, the lines that make it up a cell's border are referred to as "boxes." By maintaining borders, we are able to frame any data and give it a defined boundary in an appropriate manner. You can highlight specific values by outlining summarized values or separating data into ranges of cells; additionally, you can place borders around individual cells.

Adding borders is one of the greatest and easiest ways to make a spreadsheet seem attractive, and this is especially true if the spreadsheet is going to be printed. However, if you are consistently including new data in your spreadsheet, then you will also need to consistently update the borders of the spreadsheet. This section will show you how to add borders to your spreadsheet automatically as you add new rows of data to it.

Let’s understand step by step with an example.

Step 1

In our example, we have Student’s name, Courses, and marks in an Excel sheet in columnar format.

Step 2

Choose the range where you want to make a table, and then apply the format to all cells in that range. We choose the range from A2 to C7.

Step 3

Now, Select Conditional Formatting under Home tab in Conditional Formatting select New Rule.

Step 4

In the New Formatting Rule window, choose the Rule Type "Use a formula to determine which cells to format." Adding a formula to the Rule Description text box is the only way to define a rule. If this formula is true, the format values will be automatically applied to the cells that fulfil the rule.

Step 5

In the "Format values where this formula is true:" under Edit the Rule Description. Enter the following formula


$A$1:$C$1 is the first row in the range for cells that apply the format in the formula. The COUNTA function tells you how many cells are not blank. So, if we put a number in any cell in the range $A$1:$C$1, a table with a set format will be made.

Step 6

The Format button is right next to the Preview button. Check to see if the Format Cells window is up. Click on the Border tab, choose the style and colour of the lines in the Line frame, click Outline in the Presents menu, and make sure you can see a preview of the lines in the Border frame. A Red gridline is put on each cell.

Step 7

Then, click OK and go back to the worksheet you were on.


In some scenarios, applying automatic borders to a table range in Excel is very informative to identify the particular data based on the border color. In this tutorial, we demonstrated the steps to add borders automatically to cells.

Updated on: 10-Sep-2022

7K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started