如果单元格包含文本,则自动将文本添加到另一列单元格 [英] If cell contains a text then add text automatically to another column cell

查看:165
本文介绍了如果单元格包含文本,则自动将文本添加到另一列单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拥有两列的表格,第一列包含完成,升级,拒绝。现在我想要的是当我输入升级时,它会在另一列上生成无法在线验证。



| A | B |

|完成| |

|升级|无法在线验证|

|拒绝| |



我会尝试 = if(A2 =Escalate,HAHA,) 在列B第2行,它的工作原理,现在我想要的是将其应用于整列。例如,如果找到单词escalate在列A的任何地方,那么无法验证会出现在同一行的B列上。



有什么想法?谢谢你们!

解决方案

你必须编写一个自定义函数来完成这个任务。在您的电子表格中,按照菜单栏上的工具 - >脚本编辑器... 。最后输入以下代码:

 函数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(无法在线验证);
}
}
}

有几种方式可以调用该函数最简单的方法是在单元格中输入formuala = fillColB(),然后单击 Enter 。或者,您可以设置活动添加菜单项

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.

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..

Any idea? Thanks guys !

解决方案

You would have to write a custom function to do that. From your Spreadsheet, follow Tools-->Script Editor... on the menu bar. 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. Alternatively, you could set up an event or add a menu item.

这篇关于如果单元格包含文本,则自动将文本添加到另一列单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆