简体   繁体   English

Google 表格脚本:获取命名范围中的第一行号

[英]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.

相关问题 如何定义命名范围的第一行号? (Google表格) - How to define the first row number of a Named Range? (Google Sheets) 谷歌表格脚本:获取表格命名范围已打开 - Google Sheets Script: Get Sheet a Named Range is On Google Sheets API 脚本:尝试通过调用命名范围来获取特定列的最后一行 - Google Sheets API script: Trying to get the last row of a specific column by calling a named range 谷歌表格脚本:从当前单元格获取多列/行命名范围 - Google Sheets Script: Get Multi-Col/Row Named Range from Current Cell Google Sheets Scripts - 对于范围内的每个单元格,获取单元格具有特定值的行号,将行复制到范围内的第一个空白行 - Google Sheets Scripts - For each cell in range, get row number where cell has specific value, copy row to first blank row in range 谷歌表格脚本:为命名范围内的每个单元格获取 A1Notation - Google Sheets Script: Get A1Notation For Each Cell In Named Range Google Sheets 脚本 - 对于范围 1 中的每个使用过的单元格,如果单元格值存在于范围 2 中,则获取范围 2 匹配的行号 - Google Sheets script - For each used cell in range 1, if cell value exists in range 2, get range 2 match's row number 从命名范围Google表格脚本中选择范围 - Selecting a range from within a named range google sheets script 应用程序脚本和谷歌表格,更改命名范围的正确方法? - apps script and google sheets, proper way to change range of named range? 带有下拉菜单和将行插入命名范围的 Google 表格对话框 - Google Sheets Dialog with Dropdown and Insert Row into Named Range
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM