Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This is an event function that fires every time an change is made by a user in the sheet.
- function onEdit(e) {
- let sh = e.source.getActiveSheet();
- //If current sheet is NOT equeal (!==) to the sheetname AND (&&) range is not equal to H3. then stop the function, So if this is true is automatically points to H3....
- if (sh.getName() !== 'List of Themes' && e.range.getA1Notation() !== 'H3') return;
- //This will get the display values. Be aware!! Ifyou format a number to $50. you will get that (so you working with strings..) use getValues() instead.
- //The values are storred in a 2d array. So an array that holds an array of rows: [["A1","B1","C1"],["A2","B2","C2"],etc..]
- // Then values[0][1] would be: B1. (arrays are zero indexed)
- let values = sh.getRange('A4:F').getDisplayValues();
- //e.value is the value of the event object. (The cell that is changed.)
- switch (e.value) {
- case 'Starry Corridor':
- values.forEach((row, ind) => {
- //If column c is true then show rows else hide...
- row[2] === 'TRUE' ? sh.showRows(ind + 4) : sh.hideRows(ind + 4)
- })
- break;
- case 'Styling Theme':
- values.forEach((row, ind) => {
- row[1] === 'TRUE' ? sh.showRows(ind + 4) : sh.hideRows(ind + 4)
- })
- break;
- case 'Suggestions':
- values.forEach((row, ind) => {
- row[1] === 'FALSE' && row[2] === 'FALSE' ? sh.showRows(ind + 4) : sh.hideRows(ind + 4)
- })
- break;
- case 'Complete':
- values.forEach((row, ind) => {
- row[1] === 'TRUE' && row[2] === 'TRUE' ? sh.showRows(ind + 4) : sh.hideRows(ind + 4)
- })
- break;
- case 'All':
- default:
- sh.showRows(1, sh.getMaxRows())
- }
- }
Add Comment
Please, Sign In to add comment