XL.CopySheet
------------

Copies a sheet to another book.

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

MBS( "XL.CopySheet"; bookRef1; bookRef2; SheetIndex { ; Options } ) 

**MBS**( **"XL.CopySheet";** /\* Copies a sheet to another book. \*/  
**$bookRef1**; /\* The reference to the source workbook. Please use [XL.LoadBook](XLLoadBook.md) to load a file.e.g. $ref \*/   
**$bookRef2**; /\* The reference to the destination workbook. Please use [XL.LoadBook](XLLoadBook.md) to load a file.e.g. $ref \*/   
**$SheetIndex**; /\* The index of the sheet.   
This number ranges from 0 to [XL.Book.SheetCount](XLBookSheetCount.md)-1.e.g. 0 \*/   
**$Options**) /\* Optional; Which items to skip when copying content.e.g. "" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| bookRef1 | The reference to the source workbook. Please use [XL.LoadBook](XLLoadBook.md) to load a file. | $ref |  |
| bookRef2 | The reference to the destination workbook. Please use [XL.LoadBook](XLLoadBook.md) to load a file. | $ref |  |
| SheetIndex | The index of the sheet.    This number ranges from 0 to [XL.Book.SheetCount](XLBookSheetCount.md)-1. | 0 |  |
| Options | Which items to skip when copying content. | "" | Optional |

### Result

Returns OK or error.

### Description

Copies a sheet to another book.  
This copies most properties and all cells.  
If something is missing, please let us know.  
  
| Option | Description. |
|---|---|
| SkipPictures | Don't copy pictures. |
| SkipMerges | Don't copy merged cells. |
| SkipNamedRanges | Don't copy named ranges. |
| SkipPrintArea | Don't copy print area. |
| SkipPrintRepeat | Don't copy print repeat |
| SkipPrintFit | Don't copy print fit. |
| SkipHorPageBreak | Don't copy horizontal page breaks. |
| SkipComments | Don't copy cell comments. |
| SkipFormats | Don't copy formats. |
| SkipRowHidden | Don't copy hidden rows. |
| SkipColHidden | Don't copy hidden columns. |

### Examples

Merge two Excel documents:

 # Load 2 existing books   
Set Variable \[ $$Book\_WKPI ; Value: MBS ( "[XL.LoadBook](XLLoadBook.md)"; SheetCopy::XLSX1 ; 0 ) \]   
Set Variable \[ $$Book\_MKPI ; Value: MBS ( "[XL.LoadBook](XLLoadBook.md)"; SheetCopy::XLSX2 ; 0 ) \]   
\#   
\# Make sure sheets have names   
Set Variable \[ $mbs ; Value: MBS ( "[XL.Sheet.SetName](XLSheetSetName.md)"; $$Book\_MKPI ; 0; "Monthly" ) \]   
Set Variable \[ $mbs ; Value: MBS ( "[XL.Sheet.SetName](XLSheetSetName.md)"; $$Book\_WKPI ; 0; "Weekly" ) \]   
\#   
\# copy one to other   
Set Variable \[ $mbs ; Value: MBS ( "XL.CopySheet"; $$Book\_MKPI ; $$Book\_WKPI ; 0 ) \]   
\#   
\# save result in container   
Set Variable \[ $fileName ; Value: Substitute("Statistic\_\_" &amp; Substitute (Get(CurrentDate);".";"-") &amp; "\_" &amp; Substitute(Get(CurrentTime); ":"; "-") &amp; ".xlsx"; " Uhr"; "") \]   
Set Field \[ SheetCopy::ResultXLSX ; MBS ("[XL.Book.Save](XLBookSave.md)"; $$Book\_WKPI ; $fileName ) \]   
\#   
\# save result to desktop   
Set Variable \[ $path ; Value: Get(DesktopPath) &amp; $fileName \]   
Export Field Contents \[ SheetCopy::ResultXLSX ; “$Path ” ; Automatically open ; Create folders: Off \]   
\#   
\# Cleanup   
Set Variable \[ $r ; Value: MBS ( "[XL.Book.Release](XLBookRelease.md)"; $$Book\_MKPI ) \]   
Set Variable \[ $r ; Value: MBS ( "[XL.Book.Release](XLBookRelease.md)"; $$Book\_WKPI ) \]  
### See also

- [XL.Book.Release](XLBookRelease.md)
- [XL.Book.Save](XLBookSave.md)
- [XL.Book.SheetCount](XLBookSheetCount.md)
- [XL.LoadBook](XLLoadBook.md)
- [XL.Sheet.SetName](XLSheetSetName.md)

### Release notes

- **Version 12.5**
    - Fixed a but in [XL.CopySheet](https://www.mbsplugins.eu/XLCopySheet.shtml), where it failed if the sheet didn't have a name.
- **Version 9.0**
    - Added options for [XL.CopyContent](http://www.mbsplugins.eu/XLCopyContent.shtml), [XL.CopyRow](http://www.mbsplugins.eu/XLCopyRow.shtml), and [XL.CopySheet](http://www.mbsplugins.eu/XLCopySheet.shtml) to skip some content.

### Blog Entries

- [MBS FileMaker Plugin, version 12.5pr1](https://www.mbsplugins.de/archive/2022-09-29/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [LibXL for FileMaker with extras](https://www.mbsplugins.de/archive/2021-03-02/LibXL_for_FileMaker_with_extra/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 9.0pr7](https://www.mbsplugins.de/archive/2019-01-05/MBS_FileMaker_Plugin_version_9/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 9.0pr6](https://www.mbsplugins.de/archive/2019-01-02/MBS_FileMaker_Plugin_version_9/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 6.5pr10](https://www.mbsplugins.de/archive/2016-12-10/MBS_FileMaker_Plugin_version_6/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 1/2025, Seite 27](https://filemaker-magazin.de/neuigkeit/4282-Appetithappen-FMM_202501)

This function checks for a license.

Created 7th December 2016 , last changed 16th September 2022

  
[XL.CopyRow](XLCopyRow.md) - [XL.Date.DoubleToTimeStamp](XLDateDoubleToTimeStamp.md)

[HTML Version](XLCopySheet.shtml)