-
-
Save bran921007/df7a43d49dc976dec7535b44a1bea625 to your computer and use it in GitHub Desktop.
Google Script Spreadsheet function to iterate over all cells and insert the value 0 if the cell is blank
This file contains hidden or 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 zeroCells() { | |
var ss=SpreadsheetApp.getActiveSpreadsheet(); | |
var sheet=ss.getSheets()[0]; | |
var selection=sheet.getDataRange(); | |
var columns=selection.getNumColumns(); | |
var rows=selection.getNumRows(); | |
for (var column=1; column < columns; column++) { | |
for (var row=1; row < rows; row++) { | |
var cell=selection.getCell(row,column); | |
if (cell.isBlank()) { | |
cell.setValue(0); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment