Skip to content

Instantly share code, notes, and snippets.

@shaunmolloy
Created March 3, 2021 10:28
Show Gist options
  • Save shaunmolloy/75e958f9912b7c9393c18c725cb19adc to your computer and use it in GitHub Desktop.
Save shaunmolloy/75e958f9912b7c9393c18c725cb19adc to your computer and use it in GitHub Desktop.
Copy Down - Google Apps Script
function CopyDown() {
var sheet = SpreadsheetApp.getActive();
sheet.getCurrentCell().getNextDataCell(SpreadsheetApp.Direction.DOWN).activate();
var currentCell = sheet.getCurrentCell();
currentCell.activateAsCurrentCell();
var rangeEnd = (sheet.getSelection().getNextDataRange(SpreadsheetApp.Direction.DOWN).getLastRow()) - currentCell.getRow();
var range = sheet.getActiveSheet().getRange(currentCell.getRow(), currentCell.getColumn(), rangeEnd);
currentCell.copyTo(range, SpreadsheetApp.CopyPasteType.PASTE_VALUES, false);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment