[英]Google Sheets Script: Get First Row Number in Named Range
In a script I'm setting a range using a Named Range.在脚本中,我使用命名范围设置范围。 I need to get the first row number, to use for setting vals in other cols.我需要获取第一行号,用于在其他列中设置 vals。
The Named Range 'ASX_100' is Top5!A 8 :A107... so the first Row Number I need is 8, but as a script novice I can't find something online to help.命名范围“ASX_100”是 Top5!A 8 :A107...所以我需要的第一个行号是 8,但作为脚本新手,我无法在网上找到帮助。 My code so far:到目前为止我的代码:
const ui = SpreadsheetApp.getUi();
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sTop5 = ss.getSheetByName('Top5');
const rASX100 = ss.getRange('ASX_100'), iLen = rASX100.getNumRows();
// Get first sheet row number in range rASX100:
How should I go about this pls?我应该如何处理这个问题?
Once you have the range ( rASX100
), you can get its first row with the methods getRow() or getRowIndex() :获得范围 ( rASX100
) 后,您可以使用getRow()或getRowIndex()方法获取其第一行:
const ui = SpreadsheetApp.getUi();
const ss = SpreadsheetApp.getActiveSpreadsheet();
const sTop5 = ss.getSheetByName('Top5');
const rASX100 = ss.getRange('ASX_100'), iLen = rASX100.getNumRows();
// Get first sheet row number in range rASX100:
const firstRangeRow = rASX100.getRow();
For the last row, you can use getLastRow() .对于最后一行,您可以使用getLastRow() 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.