简体   繁体   English

google app脚本将值!= 0复制到新列中

[英]google app script copy values !=0 into new column

I am trying to copy cells with the value 0 into another cell. 我正在尝试将值为0的单元格复制到另一个单元格中。 Can't seem to get the if statement to work. 似乎无法使if语句起作用。

function pushGeo() 
{
var ssA = SpreadsheetApp.openById('###')
var ss = ssA.getSheetByName('thissheet');
var lastRow = ss.getLastRow();
  for(var row=2;row<=lastRow;row++)
  {
    if(ss.getRange('G'+row).getValue() != 0){
      var source = ss.getRange('G2:G'+lastRow); 
      var destination = ss.getRange('N2:N'+lastRow); 
      source.copyTo(destination); 
    }   
}

Right now it's copying all cells into the new column. 现在,它将所有单元格复制到新列中。

== Ah, nevermind. ==啊,没关系。 I was silly with the range. 我对范围很傻。 Time to stop coding for the day. 是时候停止编码了。

function pushGeo() 
{
  for(var row=2;row<=lastRow;row++)
  {
    if(ss.getRange('G'+row).getValue() != 0){
      var source = ss.getRange('G'+row); 
      var destination = ss.getRange('N'+row); 
      source.copyTo(destination);
    }   
  }

Ah, nevermind. 啊没关系。 I was silly with the range. 我对范围很傻。 Time to stop coding for the day. 是时候停止编码了。

function pushGeo() 
{
  for(var row=2;row<=lastRow;row++)
  {
    if(ss.getRange('G'+row).getValue() != 0){
      var source = ss.getRange('G'+row); 
      var destination = ss.getRange('N'+row); 
      source.copyTo(destination);
    }   
  }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google脚本可复制列的值并在电子表格中插入新列 - Google Script to copy the values of a column and insert a new column in spreadsheet Google表格脚本复制值从数组到列 - Google Sheets Script Copy Values from Array to Column 谷歌 Web 应用程序脚本,将带有 header 的新列添加到电子表格 - Google Web App script which add new column with header to spreadsheet Google App 脚本:仅在新电子表格中粘贴值 - Google App Script : Pasting Values only in new spreadsheet 使用 Google App Script 突出显示特定列中的最大值 - highlighting maximum values in a specific column using Google App Script 使用Google表格脚本移动过滤后的值(复制和粘贴值),而忽略列标题/标题 - Moving filtered values (copy and paste values) using google sheet script while ignoring the column heading / title Google脚本-将动态范围复制到新的电子表格 - Google Script - Copy dynamic range to new spreadsheet 将模板电子表格复制到文件夹,然后写入新副本(Google脚本) - Copy template spreadsheet to folder, then write to the new copy (google script) Google Apps脚本在新窗口中打开Goog​​le表格的副本 - Google Apps Script to Open copy of Google Sheet in new window 查找范围内值的匹配项并获取每个匹配项的第一个单元格和第一列值谷歌应用脚本 - Find matches to a value in a range and get first cell and first column values for each match google app script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM