My function should only get information from one sheet within the spreadsheet document. I tried putting the default Spreadsheet ID gid but it is not working. What do i need to do?
var pVorname = Sheets.Spreadsheets.Values.get('1MzLZ.....#gid=594...', 'B2:B100');
CodePudding user response:
In your situation, how about the following modification?
Modified script:
var pVorname = Sheets.Spreadsheets.Values.get('###spreadsheetId###', "'Sheet 3'!B2:B100");
By this modification, the values are retrieved from the range of "B2:B100" in "Sheet 3". In this case, please use the sheet name and range as the A1Notation.
###spreadsheetId###is the Spreadsheet ID. For example, when you had used1MzLZ.....#gid=594..., please modify to1MzLZ.....by removing#gid=594...as the Spreadsheet ID.From your title of
Google Apps Script. How do i specify my spreadsheet ID to "Sheet 3"?, I usedSheet 3as the sheet name.
Note:
If you are required to use the sheet ID, you can also use the following modified script.
var sheetId = "0"; var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets().find(e => e.getSheetId() == sheetId); if (sheet) { var pVorname = Sheets.Spreadsheets.Values.get(ss.getId(), `'${sheet.getSheetName()}'!B2:B100`); }
