XL.Book.InsertSheet
-------------------

Inserts a new sheet to this book at position index, returns the new sheet index.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [XL](component_XL.md) | [3.5](newinversion35.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "XL.Book.InsertSheet"; BookRef; Index; Name { ; InitSheet } ) 

**MBS**( **"XL.Book.InsertSheet";** /\* Inserts a new sheet to this book at position index, returns the new sheet index. \*/  
**$BookRef**; /\* The reference number for the workbook.e.g. $ref \*/   
**$Index**; /\* The index where to insert the sheet.e.g. 0 \*/   
**$Name**; /\* The name for the new sheet.e.g. "Taxsheet" \*/   
**$InitSheet**) /\* Optional; The index of an existing sheet to use as template.  
Must be from the same book to copy sheet.e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| BookRef | The reference number for the workbook. | $ref |  |
| Index | The index where to insert the sheet. | 0 |  |
| Name | The name for the new sheet. | "Taxsheet" |  |
| InitSheet | The index of an existing sheet to use as template.   Must be from the same book to copy sheet. | 0 | Optional |

### Result

Returns new sheet index or error message.

### Description

Inserts a new sheet to this book at position index, returns the new sheet index.   
Use initSheet parameter if you wish to copy an existing sheet.   
Note initSheet must be only from this book.   
### See also

- [XL.Book.DeleteSheet](XLBookDeleteSheet.md)
- [XL.Book.MoveSheet](XLBookMoveSheet.md)

This function checks for a license.

Created 18th August 2014 , last changed 18th May 2023

  
[XL.Book.GetText](XLBookGetText.md) - [XL.Book.IsDate1904](XLBookIsDate1904.md)

[HTML Version](XLBookInsertSheet.shtml)