Google表格:根据单元格值隐藏行是/否 [英] Google Sheets: Hiding Rows Based on Cell Value Yes/No
问题描述
我是脚本编程的新手,所以我们将不胜感激.我已经搜索并找到了一些答案,但是仍然没有找到解决方法.
I am brand new to scripting so any help would be appreciated. I have searched and found some answers but still not finding a solution.
我有一个名为测试"的简单电子表格,我具有单元格B3的数据验证.
I have a simple spreadsheet called "Test", I have data validation for cell B3.
如果用户从下拉框中输入否",则我希望隐藏以下9行.如果用户从下拉框中输入是",我希望显示以下9行.
If the user inputs "No" from the drop-down box, I want the following 9 rows hidden. if the user inputs "Yes" from the drop-down box, I want the following 9 rows to show.
就像我说的那样,有一些解决方案可供我搜索,但仍然无法产生我想要达到的结果.
Like I said there are some solutions that I have search but still not producing the result that I am trying to achieve.
推荐答案
根据验证选择隐藏和显示行
您需要添加工作表名称并为B3设置验证.
Hide and Show Rows based upon Validation Selection
You need to add the sheet name and set up the validation for B3.
function onEdit(e) {
if(e.range.columnStart==2 && e.range.rowStart==3 && e.range.getSheet().getName()=='Sheet92') {//add your sheet name
if(e.value=='Yes') {
e.range.getSheet().showRows(4,9);
}
if(e.value=='No') {
e.range.getSheet().hideRows(4,9);
}
}
}
这篇关于Google表格:根据单元格值隐藏行是/否的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!