google sheets - Apps Script - Change custom view based on value
Need some help with google sheets. The ability to changes files automatically based on value in cell A1
https://docs.google.com/spreadsheets/d/166yZQOgOZhLKoRxekNeIGUGWL91Sz3TOxHvHk-NM6n0/edit?usp=sharing
Wondering if anyone can help with this:
Desired:
Based on Value of A1
if "option1" entered in A1
- script selects Data > Change View > No1 <-- Removes all 1s
if "option2" entered in A1
-
- script selects Data > Change View > No1 <-- Removes all 5s
-
Issue:
code isn't changing anything
- what am I doing wrong?
Code:
function onEdit(e) {
const sheet = e.source.getActiveSheet();
const range = e.range;
const value = e.value;
// Check if the edited cell is your control cell (e.g., A1 on 'option1' sheet)
if (sheet.getName() === "Sheet1" && range.getA1Notation() === "A1") {
if (value === "option1") {
// Logic to show View 1 data
showDataView("No1"); // Custom function
} else if (value === "option2") {
// Logic to show View 2 data
showDataView("No5"); // Custom function
}
// Add more conditions for other values
}
}