Google Script Run函数如果在另一个表中的文本列表中包含A'特定文本'
我已经对此进行了广泛的搜索,但是它们似乎都没有用。他们都给我一张空白。
sharing?usp = sharing” b。然后做其他一些事情,分裂,修剪等...
当数据中的Col. a中的文本为250p时,我想运行此功能。
因此:if:if(data!a1:a包含文本“ 250p”,然后运行函数提取)。
这是我目前拥有的代码:
//this extract works fine but I just need this to work for only those with value 250 in Col A//
function EXTRACT() {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('A1').setFormula('=EXTRACTDATA(DATA!A1:A)');
}
function IF250() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('DATA');
var range = sheet.getRange('DATA!A1:A');
var values = range.getValues();
if (values[i] == "250g") {
EXTRACT();
更好,如果我可以将数据集中在2个单独的床单中。一张纸上的250年代&一张纸中的500。但这不是必需的。
I've done extensive search for this, but none of them seems to work. They all just give me a blank sheet.
Sample sheet
Basically I have a function that extracts data from Col. B in DATA, to Result. Then does some other things, split, trim etc...
I want to run this function when the text in Col. A in DATA is 250P.
So it would be like: IF (DATA!A1:A contains text "250p" then run function EXTRACT).
This is the code I have as of now:
//this extract works fine but I just need this to work for only those with value 250 in Col A//
function EXTRACT() {
var spreadsheet = SpreadsheetApp.getActive();
spreadsheet.getRange('A1').setFormula('=EXTRACTDATA(DATA!A1:A)');
}
function IF250() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('DATA');
var range = sheet.getRange('DATA!A1:A');
var values = range.getValues();
if (values[i] == "250g") {
EXTRACT();
Better yet, If I can have the data set in 2 separate sheets. The 250s in one sheet & 500s in one sheet. But this is not necessary.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看表格后,这是一个可能的解决方案
code.gs
After reviewing your sheet, this is a possible solution
Code.gs
尝试更改:
因为
这将读取所示的值。尝试使用两者都记录值,以了解原因! (空白)
您当前也没有迭代或循环您的值。
如果您只是想查看该列是否包含一个包含值
250p
的单元格,请尝试:注释:
Try changing:
to
As this will read the value that is shown. Try logging the values with both to see why! (Blank)
You are also not currently iterating, or looping, your values.
If you're just looking to see if the column contains a cell containing the value
250p
, try:Commented: