我想根据输入值在命名范围内的单元格中执行一些代码。
我尝试过与此类似的东西,但它似乎没有起作用:
SELECT a.*
FROM (
SELECT m.id, m.title, s.id, s.title, c.id, c.title
FROM Main m LEFT JOIN Sub s ON m.id = s.parent_main_id
LEFT JOIN Cat c ON s.id = c.parent_sub_id
UNION
SELECT m.id, m.title, s.id, s.title, p.id, p.title
FROM Main m LEFT JOIN Sub s ON m.id = s.parent_main_id
LEFT JOIN Pro p ON s.id = p.parent_sub_id
) a
ORDER BY a.id;
我猜它是if语句我做错了但我已经尝试UIImageView
和function onEdit() {
var aSheet = SpreadsheetApp.getActiveSheet();
var aCell = aSheet.getActiveCell();
var aColumn = aCell.getColumn();
var aDatarange = aSheet.getRange(aCell.getRow(),aColumn);
var aData = aDatarange.getValue();
var SomeRange = aSheet.getRangeByName('RangeName');
if (aData in 'SomeRange') {
execute some code
}
}
但似乎都没有用。
答案 0 :(得分:2)
您需要从范围中获取数据,以便可以在范围数据中搜索单元格中的值。我在您的代码中添加了几个新变量,并包含有关新代码行的注释。
function onEdit() {
var dataAsString,rangeData;
var aSheet = SpreadsheetApp.getActiveSheet();
var aCell = aSheet.getActiveCell();
var aColumn = aCell.getColumn();
var aDatarange = aSheet.getRange(aCell.getRow(),aColumn);
var aData = aDatarange.getValue();
var SomeRange = aSheet.getRangeByName('RangeName');
rangeData = SomeRange.getValues();//Get the values out of the range
dataAsString= rangeData.toString();//Convert the 2D array to a a comma seperated string of values
if (dataAsString.indexOf(aData) !== -1) {//The value of "aData" was found in the data string
//execute some code
}
}