Google 表格 - 在脚本中使用 OFFSET 中的单元格值



在Google Sheets中,我正在编写一个使用偏移函数的宏脚本:

spreadsheet.getRange('G2').offset(0,1).activate();

但是,我需要它通过特定单元格(本例中为B29)中显示的任何数字来偏移,而不是通过静态列数来偏移。如何在偏移函数中引用B29的值?

试试这样:

const bvalue =  spreadsheet.getRange('B29').getValue(); //get the value of B29
spreadsheet.getRange('G2').offset(0,bvalue).activate(); //pass it to the offset function

总是假设spreadsheet是一个您已经定义的工作表对象。

最新更新