简体   繁体   English

如果单元格包含文本,则将文本自动添加到另一个列单元格

[英]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.

相关问题 如果另一个单元格不为空,则将文本自动添加到单元格 - Add text to a cell automatically if another cell is not empty 如果单元格包含文本,则添加新行 - Add new row if cell contains text 如果单元格包含文本,则保护行 - Protect row if cell contains a text 在列中搜索文本,并使用数组列表在另一个单元格中插入文本 - Search column for text, and use array list to insert text in another cell Google 表格:如果单元格包含特定文本,则添加图像或绘图 - Google sheets: Add image or drawing if a cell contains specific text 更改单元格中的文本后自动复制信息 - Automatically copy information once text in cell was changed 当列包含特定文本 X 次时,Google Apps 脚本突出显示单元格 - Google Apps Script to highlight a cell when a column contains specific text X number of times 根据同一行的另一个单元格中的日期,自动在 Google 电子表格的单元格中插入特定文本的脚本 - Script to automatically insert a specific text in cells of a Google spreadsheet, based on a date in another cell, on the same row 如果列中的单元格包含特定字符串,则将不同的单元格值添加到其他单元格 - If a cell in a column contains a specific string, then add a different cell value to an additional cell 对于Google Appscript列中的所有单元格,将一个单元格的值添加到另一个单元格 - Add value of a cell to another cell for all cells in a column in Google Appscript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM