![](/img/trans.png)
[英]How to pass an object inside a function call of a button in google app script
[英]How to pass range object in Custom 'whenFormulaSatisfued' function in Google Script?
我正在創建一個自定義 function ,如果其長度大於 850,它將突出顯示一個單元格。我編寫了以下代碼:
colIndex = getColByName('Response');
var range = sheet.getRange(1, colIndex, sheet.getLastRow());
var rule = SpreadsheetApp.newConditionalFormatRule()
.whenFormulaSatisfied(`=LEN(${range})>850`)
.setBackground("yellow")
.setRanges([range])
.build()
var rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);
其中 getColByName() 使用 header 獲取列的索引。 這個 function 的 output 看起來像這樣:
這不能解決我的要求。 提前感謝您的幫助。
在您的情況下,如何修改如下?
.whenFormulaSatisfied(`=LEN(${range})>850`)
.whenFormulaSatisfied(`=LEN(${range.getA1Notation()})>850`)
var range = sheet.getRange(1, colIndex, sheet.getLastRow());
返回范圍 object。 我認為這可能是您的問題的原因。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.