[英]If cell contains a text then add text automatically to another column cell
I have sheet that has two columns, the first one contains "Done", "Escalate", "reject". 我的工作表有两列,第一列包含“完成”,“升级”,“拒绝”。 Now what i want is When i type escalate it will generate "unable to verify online" on the other column..
现在我想要的是,当我键入升级时,它将在另一列上生成“无法在线验证”。
| A | B |
|Done | |
|Escalate|Unable to verify online |
|Reject | |
i'd try =if(A2 = "Escalate","HAHA","")
in column B line 2 and it works, now what I want is to apply this to whole column. 我会在B列第2行中尝试
=if(A2 = "Escalate","HAHA","")
,它可以正常工作,现在我要将此内容应用于整个列。
for example, if the word escalate is found anywhere in column A then the unable to verify will appear on column B on the same row.. 例如,如果在A列中的任何位置找到“升级”一词,则无法验证将出现在同一行的B列上。
Any idea? 任何想法?
You would have to write a custom function to do that. 您将必须编写一个自定义函数来执行此操作。 From your Spreadsheet, follow
Tools-->Script Editor...
on the menu bar. 在电子表格中,按照菜单栏中的
Tools-->Script Editor...
进行操作。 Enter the following code at the end: 最后输入以下代码:
function fillColB() {
var s = SpreadsheetApp.getActiveSheet();
var data = s.getDataRange().getValues();
var data_len = data.length;
for(var i=0; i<data_len; i++) {
if(data[i][0] == "Escalate") {
s.getRange(i+1,2).setValue("unable to verify online");
}
}
}
There are several ways to call the function, simplest would be to enter the formuala =fillColB()
in a cell and click on Enter
. 有几种方法可以调用该函数,最简单的方法是在单元格中输入formuala
=fillColB()
并单击Enter
。 Alternatively, you could set up an event or add a menu item . 另外,您可以设置一个事件或添加一个菜单项 。
You can do this just with Google Sheet's Functions. 您可以仅使用Google表格的功能来执行此操作。 If you are trying to configure it based on a specific string, you can use: =IF(E5="Y",1, ) where E5 is the cell with text, "y" is the desired text in the column", 1 is the result you want to output upon the desired text, and " " is the desired output if the text is not correct.
如果要基于特定的字符串对其进行配置,则可以使用:= IF(E5 =“ Y”,1,)其中E5是具有文本的单元格,“ y”是列中所需的文本“,1是要在所需文本上输出的结果,如果文本不正确,则“”是所需输出。
If you instead want to figure out if there is any text you can use IsBlank(E5) instead of the E5="y". 如果您想弄清楚是否有任何文本,则可以使用IsBlank(E5)代替E5 =“ y”。 Ex =IF(ISBLANK(E16), ,1)
例如= IF(ISBLANK(E16),,1)
Google also has ISTEXT or ISNUM if you want to get more specific. 如果您想更具体一点,Google也提供ISTEXT或ISNUM。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.