Fill down - Google Apps Script for Spreadsheets

Mille picture Mille · Sep 27, 2012 · Viewed 60.4k times · Source

Is there a function that can fill down data to all empty cells from the row above?

If not, could anyone help me out with a Google Apps Script (or other solution) that can go through every row in my google spreadsheet, check for empty cells, and if found, fill them in with data from the row above?

Such a function should be already included in a spreadsheet program I think (and "fill up" as well).

Thank you!

Answer

AdamL picture AdamL · Sep 27, 2012

Such a function should be already included in a spreadsheet program I think (and "fill up" as well).

I'll attempt to describe the native functionality in GSheets pertaining to this.

  1. If you double-click the little blue square on the bottom-right of a selected cell or range, this will automatically fill that cell down to the end of a block of populated cells on the left. Alternatively, you can just drag this little blue box (down, up, left or right) to auto-fill.

  2. You can select the source cell and cells underneath it (refer to point 4), and then press Ctrl+Enter, to fill down. You can also use Ctrl+Enter or Ctrl+R to fill right.

  3. You can select the source cell, press Ctrl+C to copy, then select cells above (or to the left - and again refer to point 4), and then press Ctrl+V to paste. This has the effect of filling up (or left).

  4. You can quickly select blank cells under (or over, or right of, or left of) the source cell by pressing Ctrl+Shift+Down (or Up, or Right, or Left). This will take you to either the limit of the sheet, or the next populated cell. If the latter, you can then press Shift+Up (or Down, or Left, or Right) to back-track to the last blank cell. And then fill as required as per points 2 and 3.

  5. You will need to do this for each non-contiguous group of blank cells. If you want to be able to quickly auto-fill non-contiguous groups of blank cells, then yes, a script would be required.