So I got this to work off my drop down selection box.
I am sure I can use the getRowByIndex to open hide or unhide a range of rows but am unsure how to get this done
function buttonTwo(e)
{
var myGooglSheet = SpreadsheetApp.getActiveSpreadsheet();
var ui = SpreadsheetApp.getUi();
const ss = SpreadsheetApp.getActive();
const sourceSheet = ss.getSheetByName("Admin Dashboard");
const sheet = ss.getSheets()[0];
//const getRowByIndex = (index) => currentSheet.getRange(`${index}:${index}`)
//var rows = ssourceSheetheet.getRange(from, 18, where, 19).getValues();
if (!(e.range.getA1Notation() == 'C9' && e.range.getSheet().getName() == 'Admin Dashboard')) { return }
var c = sourceSheet.getRange("C9").getValue();
if ( ["Open", "Close"].indexOf(c) == -1 ) return
if ( c == "Open" )
{
if (ui.alert( "Open 2 Detected", ui.ButtonSet.OK_CANCEL) == ui.Button.CANCEL ) return
{
sourceSheet.showRows('18');
sourceSheet.showRows("19");
}
}
else
if ( c == "Close" )
{
if (ui.alert( "Close 2 Detected", ui.ButtonSet.OK_CANCEL) == ui.Button.CANCEL ) return
{
//sourceSheet.hideRows('18','19'); this closes 18 thru 37 this wont work
sourceSheet.hideRows('18'); // these work but i want to combine them into one variable
sourceSheet.hideRows('19');
}
}
}
Bookmarks