There is a keyboard shortcut to add the current date to a cell in a Google spreadsheet. But it will not enter the current time. Here's my solution. It adds a simple menu item in your spreadsheet that enables you to enter the current date and time with one click.
- Open the Tools menu and choose Script Editor
- Copy and paste the following text:
function onOpen() {
var spreadsheet = SpreadsheetApp.getActive();
var menuItems = [
{name: 'Add date and time', functionName: 'addDateTime'}
];
spreadsheet.addMenu('AddDateTime', menuItems);
}
function addDateTime() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var cell = ss.getActiveCell().setValue(new Date());
}
- Click the save button to save your script, then reload your document for the changes to take effect.
- Select the row or the cell in your spreadsheet where you want to add your data. From the Format menu, choose Number and then choose Date/Time. If you omit this step, it will only show the date without the time.
- Now select the cell where you want to add the current date. In the menu bar, look for a menu on the right that says AddDateTime. Click Add date and time to add the current date and time.
No comments:
Post a Comment