Matrix.SwapRows
---------------

Swaps two rows in the matrix.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Matrix](component_Matrix.md) | [16.2](newinversion162.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Matrix.SwapRows"; MatrixRef; Row1; Row2 ) 

**MBS**( **"Matrix.SwapRows";** /\* Swaps two rows in the matrix. \*/  
**$MatrixRef**; /\* The matrix reference number.e.g. $matrix \*/   
**$Row1**; /\* The zero based row number.e.g. 2 \*/   
**$Row2**) /\* The zero based row number.e.g. 4 \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| MatrixRef | The matrix reference number. | $matrix |
| Row1 | The zero based row number. | 2 |
| Row2 | The zero based row number. | 4 |

### Result

Returns OK or error.

### Description

Swaps two rows in the matrix.  
### Examples

Swap two rows:

 Let (\[  
 // split a CSV  
 matrix = MBS ( "[Matrix.CSVSplit](MatrixCSVSplit.md)"; "FirstName;LastName;City¶Joe;Miller;Las Vegas¶Bob;\\"Johnson-Meyer\\";\\"Köln\\"");  
 // swap first and second row  
 r = MBS ("Matrix.SwapRows"; matrix; 1; 2);  
 // and ask for text back with column names in first row  
 text = MBS ("[Matrix.CSV](MatrixCSV.md)"; matrix);  
 r = MBS ("[Matrix.Release](MatrixRelease.md)"; matrix)  
\]; text )  
### See also

- [Matrix.AddRows](MatrixAddRows.md)
- [Matrix.CSV](MatrixCSV.md)
- [Matrix.CSVSplit](MatrixCSVSplit.md)
- [Matrix.Release](MatrixRelease.md)

### Release notes

- **Version 16.2**
    - Added [Matrix.SearchAndReplace](https://www.mbsplugins.eu/MatrixSearchAndReplace.shtml), [Matrix.SwapColumns](https://www.mbsplugins.eu/MatrixSwapColumns.shtml) and [Matrix.SwapRows](https://www.mbsplugins.eu/MatrixSwapRows.shtml) functions.

### Blog Entries

- [MBS FileMaker Plugin 16.2 News](https://www.mbsplugins.de/archive/2026-05-20/MBS_FileMaker_Plugin_162_News/monkeybreadsoftware_blog_filemaker)
- [Neues MBS Plugin 16.2 für Claris FileMaker](https://www.mbsplugins.de/archive/2026-05-05/Neues_MBS_Plugin_162_für_Clar/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin 16.2 for Claris FileMaker](https://www.mbsplugins.de/archive/2026-05-05/MBS_Plugin_162_for_Claris_File/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 16.2pr1](https://www.mbsplugins.de/archive/2026-04-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 22nd March 2026 , last changed 22nd March 2026

  
[Matrix.SwapColumns](MatrixSwapColumns.md) - [Matrix.Text](MatrixText.md)

[HTML Version](MatrixSwapRows.shtml)