So I decided to remove the email notification. Now when they type Y or D, it will run the appropriate function.
I'll be updating the hide and show functions to include all the sheets. I did a quick test before I came up with this and there was no timeout when running that function.
function needEdit() {
var cellValue = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Input Info").getRange("N25").getValue();
if (cellValue == "Y") {
if(SpreadsheetApp.getActiveSheet().getRange("N25").getValue() == "Y")
{
show(); // Launches the script
}
}
if (cellValue == "Y") {
if(SpreadsheetApp.getActiveSheet().getRange("N25").getValue() == "Y")
{
showWeek1(); // Launches the script
}
}
if (cellValue == "D") {
if(SpreadsheetApp.getActiveSheet().getRange("N25").getValue() == "D")
{
hide(); // Launches the script
}
}
if (cellValue == "D") {
if(SpreadsheetApp.getActiveSheet().getRange("N25").getValue() == "D")
{
hideWeek1(); // Launches the script
}
}
}
function showWeek1() {
var sheets = ["Day 1","Day 2","Day 3","Day 4","Day 5","Day 6","Day 7","Week 1 A", "Totals (Week 1)", "Total All Weeks"];
for (var i = 0, sLen = sheets.length; i < sLen; i++) {
var sheet = SpreadsheetApp.getActive()
.getSheetByName(sheets[i])
var val = sheet.getRange('a:a')
.getValues();
for (var j = 0, vLen = val.length; j < vLen; j++) {
if (!val[j][0]) sheet.showRows(j + 1)
}
}
var ui = SpreadsheetApp.getUi();
ui.alert('You may now edit.');
}
function hideWeek1() {
var sheets = ["Day 1","Day 2","Day 3","Day 4","Day 5","Day 6","Day 7","Week 1 A", "Totals (Week 1)", "Total All Weeks"];
for (var i = 0, sLen = sheets.length; i < sLen; i++) {
var sheet = SpreadsheetApp.getActive()
.getSheetByName(sheets[i])
var val = sheet.getRange('a:a')
.getValues();
for (var j = 0, vLen = val.length; j < vLen; j++) {
if (!val[j][0]) sheet.hideRows(j + 1)
}
}
var ui = SpreadsheetApp.getUi();
ui.alert('All empty rows are now hidden. You may now edit this workbook');
}
function show() {
var ui = SpreadsheetApp.getUi();
ui.alert('You will get a message once all rows are visible.');
}
function hide() {
var ui = SpreadsheetApp.getUi();
ui.alert('You will get a message once all rows are hidden.');
}
Bookmarks