簡體   English   中英

用於從源單元格中獨立復制值的 Google 工作表腳本

[英]Google sheet script to copy a value indipendently from the source cell

我需要一個 google sheet 腳本函數,它可以在我的單元格中復制另一個單元格中公式的結果。
我需要該單元格獲得第一個結果,然后獨立於另一個單元格,因為公式結果可以變為 N/D,但我需要第二個單元格來保留該值。

您可以在另一個給定單元格中復制公式的輸出:這是一個示例:

/**
* The column B hosts the formulas and the column A hosts the output
*/
function myFunction() {
  let ss = SpreadsheetApp.getActiveSheet();
  ss.getRange("A1").setValue(ss.getRange("B1").getValue());
}

編輯:

要復制范圍,請使用.setValues().getValues()函數:

function myFunction() {
  let ss = SpreadsheetApp.getActiveSheet();
  ss.getRange("A1:A").setValues(ss.getRange("B1:B").getValues());
}

參考:

getValue setValue getValues setValues

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM