Excel has a number of "automatic" features, which can be more efficient if used properly. After the experiment, I found a way to use conditional formatting to automatically add borders to Excel cells, which is "the key, row is table." The following are the specific steps:
1. In the first row, select the area where you want to display the border, such as the a1:d1 in this example.
2. Perform "format" → "conditional formatting" to open the Conditional Formatting dialog box. Click to open the condition 1 drop-down list, click Select Formula, and then enter the following formula in the box below "=or ($A 1<>" ", $B 1<>" ", $C 1<>" ", $D 1<>" "), meaning that as long as A1, B1, C1 or D1 has data in one cell, the outer border is automatically added to these four cells.
Note: The cell reference in the formula is a mixed reference, and the effect is different if you change to a relative reference, and friends can try.
3. Click the Format button to open the Format Cells dialog box, switch to the Borders tab, and specify an outline for cells that match the criteria. As shown in Figure 1.
4. Select A1:d1 area, copy, select A→d column, paste (if you have entered data in A1:d1, perform "edit" → "paste Selective" → "format"), so that the format set in step 2nd is assigned to all cells in the A→d column. As shown in Figure 2.
Enter data (including spaces) in any of these four columns, and the cells in this row (a→d column) will automatically add a border. As shown in Figure 3.
Tip: For cells that have the border set for a conditional format, it still allows you to set its border in the Borders tab of the Cell Format dialog box, but the outline box cannot be displayed (as is the case with the Border button on the toolbar), only slashes are displayed unless you delete all the data in the criteria range.