sorry for the trouble. I can’t get the second sheet’s URL. Please tell me how to get the URL of the second sheet? [email protected]
function myFunction() {
const ss = SpreadsheetApp.getActiveSpreadsheet().getSheets()[1];
const name =ss.getSheetName();
Logger.log(name); // ok
const value = ss.getRange('C2').getValue();
Logger.log(value); // ok
Logger.log(ss.getUrl()); // TypeError: ss.getUrl is not a function. Please help
}
I tried this method to get the second sheet’s URL. But I am getting two same urls.
function myFunction() {
const sl = SpreadsheetApp.getActiveSpreadsheet();
console.log(sl.getUrl())
sl.insertSheet('xyz',1);
const nm = sl.getSheetByName("xyz");
nm.activate();
const spsh = SpreadsheetApp.getActiveSpreadsheet();
console.log(spsh.getUrl());}
New contributor
Iliuha Ipatii is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.