Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I was going to point out <a href="https://webapps.stackexchange.com/questions/17238/adding-a-datepicker-in-google-spreadsheet">Adding a datepicker in Google Spreadsheet</a> on WebApps, but you found it.</p> <p>As you have noted, a datepicker will only be present if there is a valid date in a cell. There is also no programmatic control over the datepicker widget.</p> <p>This function will fill every cell in any range with the same default value, and that value can be any type supported by the spreadsheet.</p> <pre><code>/** * Fill a range with a default value. * * @param {Range} rangeFill A spreadsheet range to be filled * @param {Object} value The default value to fill the range with */ function rangeDefault( rangeFill, value ) { // Fill a two-dimensional array with default values var defaults = [[]]; // Dimension the array to match the input range var height = rangeFill.getLastRow() - rangeFill.getRow() + 1; var width = rangeFill.getLastColumn() - rangeFill.getColumn() + 1; for (var row=0; row &lt; height; row++ ) { defaults[row]=[]; for (var col=0; col &lt; width; col++ ) { defaults[row][col] = value; } } // Fill the range with the array contents. rangeFill.setValues(defaults); } </code></pre> <p>To make it easy to use in a spreadsheet, here's a menu function. Just select the range you want filled, then pick "Date Fill" from the "Custom Menu", and the selection will be filled with today's date.</p> <pre><code>/** * Menu function - fill the currently selected range with today's date. */ function dateFill() { var today = new Date(); var defaultDate = new Date( today.getFullYear(), today.getMonth()+1, today.getDate() ); rangeDefault( SpreadsheetApp.getActiveSpreadsheet().getActiveRange(), defaultDate); } function onOpen() { var sheet = SpreadsheetApp.getActiveSpreadsheet(); var entries = [{ name : "Date Fill", functionName : "dateFill" }]; sheet.addMenu("Custom Menu", entries); }; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload