Skip to main content

SHEET

Returns the sheet number of the reference sheet.

Syntax​

expression.SHEET(arg1);

expression - A variable that represents a ApiWorksheetFunction class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
arg1Optionalstring | ApiRange | ApiNameThe name of a sheet or a reference for which the sheet number will be returned. If omitted the number of the sheet containing the function is returned.

Returns​

number

Example​

Return the sheet number of the reference sheet in a spreadsheet.

// Retrieve the sheet number for a given sheet reference using the SHEET function.

// Apply the function to display the sheet index in a cell.

const worksheet = Api.GetActiveSheet();
let func = Api.WorksheetFunction;
let result = func.SHEET("Sheet1");
worksheet.GetRange("C3").SetValue(result);