简体   繁体   English

如何在 Google 表格脚本编辑器的字符串中使用变量?

[英]How to use a variable in a string in Google Sheets Script Editor?

I'm a newbie to Script Editor, so I need some help.我是脚本编辑器的新手,所以我需要一些帮助。

function makeitright(){
var app1 = SpreadsheetApp;
var ss1 = app1.getActiveSpreadsheet();
var cred = ss1.getSheetByName("Crédito");
var lastrow = cred.getLastRow(); 

var formmod = 'ISBLANK('"H"+(lastrow+1)')'')';

I'm trying to write a formula to a single cell.我正在尝试将公式写入单个单元格。 But this formula will always change with a new added row.但是这个公式总是会随着新添加的行而改变。 So I need the formula to work with the variable that gets the lastrow + 1.所以我需要公式来处理获得 lastrow + 1 的变量。

Any ideas in how this could be made?关于如何做到这一点的任何想法?

replace代替

'ISBLANK('"H"+(lastrow+1)')'')';

by经过

 'ISBLANK(H' + ( lastrow + 1 ) + ')';

To learn more read about how string concatenation works in JavaScript.要了解有关字符串连接如何在 JavaScript 中工作的更多信息。

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

相关问题 使用按钮和脚本编辑器更新单元格 Google 表格中的日期值 - Use button and script editor to update a date value in cell Google sheets 如何解决“平均值”未在Google表格脚本编辑器中定义的问题? - How to fix “average” is not defined in google sheets script editor? 延迟使用Google脚本编辑器(适用于Google表格) - Delay on Google Script Editor (For Google Sheets) 如何使用包含布尔值的全局变量来更改谷歌表格脚本中的其他变量? - How do I use global a global variable containing a boolean to change other variable in google sheets script? 使用谷歌脚本编辑器 - use of google script editor 在 Google 表格的脚本编辑器中将参数添加到 function - Adding parameters to function in script editor for google sheets Google表格脚本编辑器触发器不起作用 - Google Sheets Script Editor Triggers not Working Google Sheets 脚本编辑器:默认时区 - Google Sheets script editor: default timezone 是否可以在Google Apps脚本表格的copyTo命令中使用变量? - Is it possible to use a variable in the copyTo command in Google Apps Script for Sheets? 获取Google Analytics(分析)访问令牌以及如何在Google表格脚本中使用它 - getting a google analytics access token and how to use it in google sheets script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM