Created
March 3, 2021 10:28
-
-
Save shaunmolloy/75e958f9912b7c9393c18c725cb19adc to your computer and use it in GitHub Desktop.
Copy Down - Google Apps Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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