我正在为Google Spreadsheets构建一个脚本,用于创建动态下拉列表。这是用JavaScript编写的,但这是我工作过的第一个,需要一些逻辑方面的帮助。
代码有效但现在我想要的是让B列和C列依赖于A列中选择的类别。
以下脚本有三个级别:主要类别,子组(取决于主要类别)和子子组(取决于子组)。
所以在我的情况下,我正在为多个属性标记视频内容。所以主要类别可能是"音频"我想为同一个子组中的两个项目标记它。
基本上我怎么能让B列和C列只依赖于使用下面脚本从A列中选择?
我很确定我需要在这里调整一些内容: tryFibo(fiboSequence, 1100);
tryFibo(fiboSequence, 100);
tryFibo(fiboSequence, 100);
tryFibo(fiboSequence, 200);
tryFibo(fiboSequence, 1100);
tryFibo(fiboSequence, 2100);
tryFibo(fiboSequence, 2100);
tryFibo(fiboSequence, 1100);
tryFibo(fiboSequence, 100);
tryFibo(fiboSequence, 100);
tryFibo(fiboSequence, 200);
tryFibo(fiboSequence, 1100);
1
1
2
3
5
8
13
21
34
55
failed counting f(1100), time=3.555689 ns
repeated timing for f(100)=0.213156 ns
repeated timing for f(100)=0.002444 ns
repeated timing for f(200)=0.266933 ns
repeated timing for f(1100)=5.457956 ns
repeated timing for f(2100)=3.016445 ns
repeated timing for f(2100)=0.001467 ns
repeated timing for f(1100)=0.005378 ns
repeated timing for f(100)=0.002934 ns
repeated timing for f(100)=0.002445 ns
repeated timing for f(200)=0.002445 ns
repeated timing for f(1100)=0.003911 ns
答案 0 :(得分:0)
以下是一些可能有用的代码。我还没有测试过,但看看我做了些什么;弄清楚代码中的逻辑和改进;运行它,看看会发生什么。如果您发现错误或意外结果,请告诉我。
function onEdit(e) { //Use the event - e
var ss = SpreadsheetApp.getActiveSpreadsheet(); //get spreadsheet - ss
var sh = ss.getActiveSheet(); //get sheet - sh
var cellRng = e.range; //Range of cell that was edited
var rowEdited = cellRng.getRow();
var columnEdited = cellRng.getColumn();
var range; //define a variable for a range, and leave it undefined
if (columnEdited === 1) {//If column one was edited, change the data validation in the next column
//Run the function to update the validation twice, once for column B, once for column C
range = sh.getRange(rowEdited, columnEdited + 1); //Update Column B
depDrop_(range, cellRng);
range = sh.getRange(rowEdited, columnEdited + 2); //Update column C
depDrop_(range, cellRng);
};
//If column 1 was not edited, then do nothing
};