XL.Sheet.RemoveRow
------------------

Removes rows from rowFirst to rowLast.

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

MBS( "XL.Sheet.RemoveRow"; BookRef; SheetIndex; rowFirst; rowLast { ; KeepRanges } ) 

**MBS**( **"XL.Sheet.RemoveRow";** /\* Removes rows from rowFirst to rowLast. \*/  
**$BookRef**; /\* The reference number for the workbook.e.g. $ref \*/   
**$SheetIndex**; /\* The index of the sheet. This number ranges from 0 to [XL.Book.SheetCount](XLBookSheetCount.md)-1.e.g. 0 \*/   
**$rowFirst**; /\* The first row for the area. First row has index 0.e.g. $row \*/   
**$rowLast**; /\* The last row for the area.e.g. $row+1 \*/   
**$KeepRanges**) /\* Optional; If 1, the ranges are kept and not updated.  
Default is 0 to update ranges.e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| BookRef | The reference number for the workbook. | $ref |  |
| SheetIndex | The index of the sheet. This number ranges from 0 to [XL.Book.SheetCount](XLBookSheetCount.md)-1. | 0 |  |
| rowFirst | The first row for the area. First row has index 0. | $row |  |
| rowLast | The last row for the area. | $row+1 |  |
| KeepRanges | If 1, the ranges are kept and not updated.   Default is 0 to update ranges. | 0 | Optional      Added in version **10.2**. |

### Result

Returns OK or error.

### Description

Removes rows from rowFirst to rowLast.   
### Examples

Preprocess file before import in FileMaker by removing a row and a sheet:

 # Find libXL and load it   
If \[ MBS ("[XL.IsInitialized](XLIsInitialized.md)") ≠ 1 \]   
 Perform Script \[ Specified: From list ; “InitXL” ; Parameter: \]  
End If  
\#   
\# path to xls or xlsx file   
Set Variable \[ $path ; Value: MBS ( "[Path.AddPathComponent](PathAddPathComponent.md)"; MBS ( "[Folders.UserDesktop](FoldersUserDesktop.md)" ); "test.xls" ) \]   
\#   
\# Load template excel file   
Set Variable \[ $bookRef ; Value: MBS ( "[XL.LoadBook](XLLoadBook.md)"; $path ) \]   
If \[ MBS ("IsError") \]   
 Show Custom Dialog \[ "Error" ; $bookRef \]   
 Exit Script \[ Text Result: \]   
End If  
\#   
\# Remove first row of first sheet   
Set Variable \[ $r ; Value: MBS ( "XL.Sheet.RemoveRow"; $BookRef ; 0 /\* sheet index \*/; 0 /\* row index \*/) \]   
\#   
\# Remove second sheet   
Set Variable \[ $r ; Value: MBS ( "[XL.Book.DeleteSheet](XLBookDeleteSheet.md)"; $bookRef ; 1 /\* sheet index \*/ ) \]   
\#   
\# Save to file and cleanup   
Set Field \[ XL::OutputFile ; MBS ("[XL.Book.SaveToFile](XLBookSaveToFile.md)"; $bookRef ; $path ) \]   
Set Variable \[ $r ; Value: MBS ( "[XL.Book.Release](XLBookRelease.md)"; $bookRef ) \]   
\#   
\# now let FileMaker import file   
Remove three rows:

 Set Variable \[ $r ; Value: MBS ( "XL.Sheet.RemoveRow"; $book ; $sheet ; 3; 5; 1) \]  
### See also

- [Folders.UserDesktop](FoldersUserDesktop.md)
- [IsError](IsError.md)
- [Path.AddPathComponent](PathAddPathComponent.md)
- [XL.Book.DeleteSheet](XLBookDeleteSheet.md)
- [XL.Book.Release](XLBookRelease.md)
- [XL.Book.Save](XLBookSave.md)
- [XL.Book.SheetCount](XLBookSheetCount.md)
- [XL.IsInitialized](XLIsInitialized.md)
- [XL.LoadBook](XLLoadBook.md)
- [XL.Sheet.RemoveCol](XLSheetRemoveCol.md)

This function checks for a license.

Created 18th August 2014 , last changed 4th September 2025

  
[XL.Sheet.RemovePictureByIndex](XLSheetRemovePictureByIndex.md) - [XL.Sheet.RemoveSelection](XLSheetRemoveSelection.md)

[HTML Version](XLSheetRemoveRow.shtml)