Google Apps脚本计数是否 [英] Google apps script count if

查看:72
本文介绍了Google Apps脚本计数是否的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Juan已解决了我的问题(以下是我的第一个要求,以斜体显示).但是我正在尝试第二件事:

My problem has been resolved by Juan (below in italic my first request). However I am trying a second thing :

我有一个包含2列的google电子表格. 第一列名称(杰夫,丹尼尔...) 第二列的值(1、2、3 ...) 我想创建一个简单的脚本,该脚本从顶部读取所有行,并输出值等于或大于20的数字.并在单元格C2中显示结果. 我不知道该怎么做. 非常感谢能做到这一点的人.

I have a google spreadsheet with 2 columns. 1st column with names (jeff, daniel...) 2nd column with value (1, 2, 3...) I would like to create a simple script which reads all the row from the top and output the number with value 20 or more. And to display the results in cell C2. I cant figure out how to do it. Thank you a lot for the one who can do it.

如何编写一个简单的脚本来知道我的B列中有多少个值大于20"(仍然在考虑我的第一个问题是我的电子表格),并在例如单元格D2中获得结果?

How is it possible to write a simple script to know "how many value are above 20 in my column B" (still considering my spreadsheet for my first question) and to get the result in cell D2 for example ?

再次感谢您的宝贵时间.我真的为此而苦苦挣扎

Thanks again for your time. I am really struggling with that

推荐答案

尝试一下...

function myFunction() {
  var data = SpreadsheetApp.getActive().getSheetByName("Sheet1").getDataRange().getValues();

  for (var i =0; i < data.length; i++){
    var column2 = data[i][1];


    if (column2 >= 20){
      var column3 = SpreadsheetApp.getActive().getSheetByName("Sheet1").getRange(i +1, 3).setValue("value to add on column 3");

    }
  }
}

这篇关于Google Apps脚本计数是否的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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