Skip to content

Instantly share code, notes, and snippets.

@cyberdev
Last active February 9, 2021 03:57
Show Gist options
  • Save cyberdev/016bc9985950fb1bc2b60e094097cd82 to your computer and use it in GitHub Desktop.
Save cyberdev/016bc9985950fb1bc2b60e094097cd82 to your computer and use it in GitHub Desktop.
Hide & Unhide Sheets Row
//col and row position of status check
const ROW_CHECK = 2
const COL_CHECK = 2
//row and col index to be hide and unhide
const ROW_TO_HIDE = 10
const COL_TO_HIDE = 1
//row count to be hide and unhide
var ROW_HIDE_COUNT = 11
function onEdit(e){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var sheetName = sheet.getName();
//--------------------New script--------------------
if(sheetName=='Sheet1' || sheetName=='Sheet2' || sheetName=='Sheet3'){
var rg = sheet.getRange(ROW_CHECK, COL_CHECK);
if (rg.getValue() != "" && rg.getValue() != null) {
pasted = true
var range = sheet.getRange(ROW_TO_HIDE, COL_TO_HIDE, ROW_HIDE_COUNT);
sheet.unhideRow(range);
}else{
sheet.hideRows(ROW_TO_HIDE, ROW_HIDE_COUNT);
}
}
//----------------------------------------------------
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment