79217857

Date: 2024-11-23 12:49:46
Score: 1
Natty:
Report link

Here's another solution. It's a little known fact that Google Sheets supports conditional formatting rules for borders when those rules have been imported from an Excel file.

I took your sample spreadsheet and exported it as an Excel file. Once opened in Excel, I created the following three CF rules. Conditional Formatting rules within Excel

First row: For C10:G10, I applied the solid top, left, and right border along with the dotted line for the bottom using custom formula:

=COUNTA($C10:$G10)>0.

Mid rows: For C11:G100, I used the solid left and right borders plus the dotted top and bottom border using custom formula:

=COUNTA($C11:$G11)>0.

Bottom row: For the same range, I used the custom formula:

=(COUNTA($C11:$G11)=0)*(COUNTA($C10:$G10)>0)>0

This identified the bottom row, for which I made the top border dotted and the left, right, and bottom borders solid.

Once those were created, I downloaded the .xlsx file and imported it into Sheets.

The result, instant dynamic borders without the use of Apps Script.

Dynamic table border without using Apps Script

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: bricks96