SHEETS function
PRO
The SHEETS function in Jspreadsheet Formulas Pro is a simple tool that tells you how many sheets are in a specific reference. This could be particularly useful if you're working with a large workbook and want a quick way to count all the sheets. You simply input the reference you're interested in and it will return the total number of sheets included. It's a handy way to keep track of your data organization in Jspreadsheet.
Documentation
Returns the number of sheets in a reference.
Category
Information
Syntax
SHEETS([reference])
| Parameter | Description | 
|---|---|
reference | 
Optional. A reference to a cell or range of cells in the same workbook. If omitted, returns the number of sheets in the entire workbook. | 
Behavior
The SHEETS function in returns the number of sheets in a reference. The behavior of the SHEETS function is as follows:
- The 
SHEETSfunction counts all the sheets in the workbook if no argument is provided. - If a reference is provided, the 
SHEETSfunction will count all the sheets in the workbook which the reference spans. - Empty cells, text, booleans, and errors are irrelevant to the 
SHEETSfunction as it only counts the number of sheets. - The 
SHEETSfunction doesn't evaluate the contents of the sheets; it just counts the number of sheets. 
Common Errors
| Error | Description | 
|---|---|
| #REF! | This error occurs if the provided reference is invalid. | 
| #N/A | This error occurs if the reference does not exist. | 
| #VALUE! | This error occurs if the supplied argument is a non-numeric value. | 
Best practices
- Always ensure that the references provided to the
 SHEETSfunction are valid to avoid errors.- Use the
 SHEETSfunction without any arguments to get the total number of sheets in a workbook.- Be cautious of the workbook structure when using the
 SHEETSfunction as adding or removing sheets will affect the output of the function.- Use the
 SHEETSfunction in combination with other functions likeINDEXandMATCHto navigate large workbooks more effectively.
Usage
A few examples using the SHEETS function.
SHEETS() returns the total number of sheets in the workbook  
SHEETS(Annual!A1:C10) returns the number of sheets that contain data referenced in Annual!A1:C10  
SHEETS(Sheet3!D4:E8) returns 1 if Sheet3 is the only sheet containing data referenced in the specified range  
Interactive Spreadsheet Demo
<html>
<script src="https://jspreadsheet.com/v11/jspreadsheet.js"></script>
<script src="https://jsuites.net/v5/jsuites.js"></script>
<link rel="stylesheet" href="https://jsuites.net/v5/jsuites.css" type="text/css" />
<link rel="stylesheet" href="https://jspreadsheet.com/v11/jspreadsheet.css" type="text/css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons" />
<script src="https://cdn.jsdelivr.net/npm/@jspreadsheet/formula-pro/dist/index.min.js"></script>
<div id="spreadsheet"></div>
<script>
// Set your JSS license key (The following key only works for one day)
jspreadsheet.setLicense('ODMwNTg3OGNiOTUxOGQ2NzMxY2NkYmM3ZTJkNzU5YzNmNWNhYTAwOTYyODg0NzQwNzgyODU3ZmVkZTZlOWU3MDVkZjFlZmFmM2QxODgxNTI0N2RlNzliNDFiMjJiNGI0MzFkODM4ZmY5OTRkYTJhNjFmNDFmOGMwZjcyNDA2NzAsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpZeU16QTFPRGN5TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0ltTm9ZWEowY3lJc0ltWnZjbTF6SWl3aVptOXliWFZzWVNJc0luQmhjbk5sY2lJc0luSmxibVJsY2lJc0ltTnZiVzFsYm5Seklpd2lhVzF3YjNKMFpYSWlMQ0ppWVhJaUxDSjJZV3hwWkdGMGFXOXVjeUlzSW5ObFlYSmphQ0lzSW5CeWFXNTBJaXdpYzJobFpYUnpJaXdpWTJ4cFpXNTBJaXdpYzJWeWRtVnlJaXdpYzJoaGNHVnpJaXdpWm05eWJXRjBJbDBzSW1SbGJXOGlPblJ5ZFdWOQ==');
// Set the extensions
jspreadsheet.setExtensions({ formula });
// Create a new spreadsheet
jspreadsheet(document.getElementById('spreadsheet'), {
  worksheets: [{
    data: [
    [
        "Workbook Analysis",
        "Sheet Count"
    ],
    [
        "Total sheets in workbook",
        "=SHEETS()"
    ],
    [
        "Sheets with data in range",
        "=SHEETS(Sheet1!A1:B10)"
    ],
    [
        "Single sheet reference",
        "=SHEETS(Summary!C1:D5)"
    ]
]
  }]
});
</script>
</html>
import React, { useRef } from "react";
import { Spreadsheet, Worksheet, jspreadsheet } from "@jspreadsheet/react";
import formula from "@jspreadsheet/formula-pro";
import "jsuites/dist/jsuites.css";
import "jspreadsheet/dist/jspreadsheet.css";
// Set license
jspreadsheet.setLicense('ODMwNTg3OGNiOTUxOGQ2NzMxY2NkYmM3ZTJkNzU5YzNmNWNhYTAwOTYyODg0NzQwNzgyODU3ZmVkZTZlOWU3MDVkZjFlZmFmM2QxODgxNTI0N2RlNzliNDFiMjJiNGI0MzFkODM4ZmY5OTRkYTJhNjFmNDFmOGMwZjcyNDA2NzAsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpZeU16QTFPRGN5TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0ltTm9ZWEowY3lJc0ltWnZjbTF6SWl3aVptOXliWFZzWVNJc0luQmhjbk5sY2lJc0luSmxibVJsY2lJc0ltTnZiVzFsYm5Seklpd2lhVzF3YjNKMFpYSWlMQ0ppWVhJaUxDSjJZV3hwWkdGMGFXOXVjeUlzSW5ObFlYSmphQ0lzSW5CeWFXNTBJaXdpYzJobFpYUnpJaXdpWTJ4cFpXNTBJaXdpYzJWeWRtVnlJaXdpYzJoaGNHVnpJaXdpWm05eWJXRjBJbDBzSW1SbGJXOGlPblJ5ZFdWOQ==');
// Set the extensions
jspreadsheet.setExtensions({ formula });
export default function App() {
    // Spreadsheet array of worksheets
    const spreadsheet = useRef();
    // Worksheet data
    const data = [
    [
        "Workbook Analysis",
        "Sheet Count"
    ],
    [
        "Total sheets in workbook",
        "=SHEETS()"
    ],
    [
        "Sheets with data in range",
        "=SHEETS(Sheet1!A1:B10)"
    ],
    [
        "Single sheet reference",
        "=SHEETS(Summary!C1:D5)"
    ]
];
    // Render component
    return (
        <Spreadsheet ref={spreadsheet}>
            <Worksheet data={data} />
        </Spreadsheet>
    );
}
<template>
    <Spreadsheet ref="spreadsheet">
        <Worksheet :data="data" />
    </Spreadsheet>
</template>
<script>
import { Spreadsheet, Worksheet, jspreadsheet } from "@jspreadsheet/vue";
import "jsuites/dist/jsuites.css";
import "jspreadsheet/dist/jspreadsheet.css";
import formula from "@jspreadsheet/formula-pro";
// Set license
jspreadsheet.setLicense('ODMwNTg3OGNiOTUxOGQ2NzMxY2NkYmM3ZTJkNzU5YzNmNWNhYTAwOTYyODg0NzQwNzgyODU3ZmVkZTZlOWU3MDVkZjFlZmFmM2QxODgxNTI0N2RlNzliNDFiMjJiNGI0MzFkODM4ZmY5OTRkYTJhNjFmNDFmOGMwZjcyNDA2NzAsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpZeU16QTFPRGN5TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0ltTm9ZWEowY3lJc0ltWnZjbTF6SWl3aVptOXliWFZzWVNJc0luQmhjbk5sY2lJc0luSmxibVJsY2lJc0ltTnZiVzFsYm5Seklpd2lhVzF3YjNKMFpYSWlMQ0ppWVhJaUxDSjJZV3hwWkdGMGFXOXVjeUlzSW5ObFlYSmphQ0lzSW5CeWFXNTBJaXdpYzJobFpYUnpJaXdpWTJ4cFpXNTBJaXdpYzJWeWRtVnlJaXdpYzJoaGNHVnpJaXdpWm05eWJXRjBJbDBzSW1SbGJXOGlPblJ5ZFdWOQ==');
// Set the extensions
jspreadsheet.setExtensions({ formula });
export default {
    components: {
        Spreadsheet,
        Worksheet,
    },
    data() {
        // Worksheet data
        const data = [
    [
        "Workbook Analysis",
        "Sheet Count"
    ],
    [
        "Total sheets in workbook",
        "=SHEETS()"
    ],
    [
        "Sheets with data in range",
        "=SHEETS(Sheet1!A1:B10)"
    ],
    [
        "Single sheet reference",
        "=SHEETS(Summary!C1:D5)"
    ]
]
        return {
            data
        };
    }
}
</script>
import { Component, ViewChild, ElementRef } from "@angular/core";
import jspreadsheet from "jspreadsheet";
import * as formula from "@jspreadsheet/formula-pro";
// Set your JSS license key (The following key only works for one day)
jspreadsheet.setLicense('ODMwNTg3OGNiOTUxOGQ2NzMxY2NkYmM3ZTJkNzU5YzNmNWNhYTAwOTYyODg0NzQwNzgyODU3ZmVkZTZlOWU3MDVkZjFlZmFmM2QxODgxNTI0N2RlNzliNDFiMjJiNGI0MzFkODM4ZmY5OTRkYTJhNjFmNDFmOGMwZjcyNDA2NzAsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpZeU16QTFPRGN5TENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0ltTm9ZWEowY3lJc0ltWnZjbTF6SWl3aVptOXliWFZzWVNJc0luQmhjbk5sY2lJc0luSmxibVJsY2lJc0ltTnZiVzFsYm5Seklpd2lhVzF3YjNKMFpYSWlMQ0ppWVhJaUxDSjJZV3hwWkdGMGFXOXVjeUlzSW5ObFlYSmphQ0lzSW5CeWFXNTBJaXdpYzJobFpYUnpJaXdpWTJ4cFpXNTBJaXdpYzJWeWRtVnlJaXdpYzJoaGNHVnpJaXdpWm05eWJXRjBJbDBzSW1SbGJXOGlPblJ5ZFdWOQ==');
// Set the extensions
jspreadsheet.setExtensions({ formula });
@Component({
    standalone: true,
    selector: "app-root",
    template: `<div #spreadsheet></div>`
})
export class AppComponent {
    @ViewChild("spreadsheet") spreadsheet: ElementRef;
    // Worksheets
    worksheets: jspreadsheet.worksheetInstance[];
    // Create a new data grid
    ngAfterViewInit() {
        // Create spreadsheet
        this.worksheets = jspreadsheet(this.spreadsheet.nativeElement, {
            worksheets: [{
                data: [
    [
        "Workbook Analysis",
        "Sheet Count"
    ],
    [
        "Total sheets in workbook",
        "=SHEETS()"
    ],
    [
        "Sheets with data in range",
        "=SHEETS(Sheet1!A1:B10)"
    ],
    [
        "Single sheet reference",
        "=SHEETS(Summary!C1:D5)"
    ]
]
            }]
        });
    }
}