COUNTHIDDENSHEETS

COUNTHIDDENSHEETS()
Returns the number of hidden worksheets in the active workbook


REMARKS
You can use the built-in worksheet function SHEETS() in Excel 2013 to return the number of sheets in the active workbook.

 A
1??

Public Function COUNTHIDDENSHEETS() As Integer 

End Function

await Excel.run(async (context) => {
    const sheets = context.workbook.worksheets;
    sheets.load("items/visibility");
    await context.sync();

    let hiddenCount = 0;
    let veryHiddenCount = 0;

    sheets.items.forEach(sheet => {
        if (sheet.visibility === Excel.SheetVisibility.hidden) {
            hiddenCount++;
        }
        if (sheet.visibility === Excel.SheetVisibility.veryHidden) {
            veryHiddenCount++;
        }
    });

    console.log("Hidden:", hiddenCount);
    console.log("Very Hidden:", veryHiddenCount);
});

© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext