是否有一个脚本可以在列表中的所有单元格上创建链接,并且一旦您单击它们就会将您发送到相应的(同名)选项卡?

Is there a script that can create links on all cells from a list and once you click on them to send you to the respective (same named) tabs?

我有一个包含 10 个项目的列表,并创建了 10 个以这 10 个项目命名的选项卡。是否有一个脚本可以在列表名称单元格上创建链接,并且一旦您单击它们就会将您发送到相应的(同名)选项卡?

使用这个脚本:

function SHEETLIST() {
try {
  var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets()
  var out = new Array( sheets.length+1 ) ;
  out[0] = [ "NAME" , "#GID" ];
  for (var i = 1 ; i < sheets.length+1 ; i++ ) out[i] = 
  [sheets[i-1].getName() , sheets[i-1].getSheetId() ];
  return out
}
catch( err ) {
  return "#ERROR!" 
}
}

然后这个公式:

=ARRAYFORMULA(HYPERLINK("#gid="&
 QUERY(INDEX(SHEETLIST();;2); "offset 1"); 
 QUERY(INDEX(SHEETLIST();;1); "offset 1")))