我找到了一个脚本,该脚本按值隐藏行。我需要一个工作原理相同的脚本,但是我需要能够在不同的值之间切换。在我的情况下,我有多个位置,并且我想根据每行的单元格值分别显示所有位置/行或每个位置/值。可以通过“数据验证”->项目列表来选择该值。
/**
* TITLE:
* Hide a row if a value is inputted.
*/
//**GLOBALS**
// Sheet the data is on.
var SHEET = "D&D Miniatures";
// The value that will cause the row to hide.
var VALUE = "Yes";
// The column we will be using
var COLUMN_NUMBER = 6
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var activeSheet = ss.getActiveSheet();
//Ensure on correct sheet.
if(SHEET == activeSheet.getName()){
var cell = ss.getActiveCell()
var cellValue = cell.getValue();
//Ensure we are looking at the correct column.
if(cell.getColumn() == COLUMN_NUMBER){
//If the cell matched the value we require,hide the row.
if(cellValue == VALUE){
activeSheet.hideRow(cell);
};
};
};
}