I'm looking to have cell borders automatically applied when a cell is not empty. I thought I could use conditional formatting for this, but it doesn't seem to be an option.
Google-sheets – Automatically add borders around nonempty cells
conditional formattinggoogle sheets
Related Topic
- Google-sheets – Conditional formatting over wide area of cells, referencing other cells
- Google Sheets – Conditional Formatting with Multiple Criteria for a Range of Cells
- Google Sheets – How to Conditionally Format Row Borders
- Google Sheets – Use Checkbox to Change Background Color of Cells
- Google Sheets – How to Create Dynamic Borders for Columns
- Google Sheets – Apply Conditional Formatting to a Blank Cell Based on Another Cell
- Google-sheets – How to check and replace cells
Best Answer
This is possible with a script ("Tools > Script editor"), using setBorder method. Here is a little demo script
This runs on every edit, puts borders on the active cell/range if it's nonempty, removes them otherwise.
However, the above logic is too simple. If a cell is made blank by an edit, but has non-blank neighbors, some borders should be kept. Here is a version that addresses this by removing all borders and repainting them around non-blank cells.
But the constant flashing of all borders is annoying and slow and annoying. It's better to have this painting job invoked manually, via a menu. Here's my final version of the script: it adds a menu item "Custom > Borders for nonempty cells" whenever the spreadsheet is opened.