XL.Sheet.SetColPx
-----------------

Sets column width in pixels and format for all columns from colFirst to colLast.

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

MBS( "XL.Sheet.SetColPx"; BookRef; SheetIndex; ColFirst; ColLast; Width { ; Format; Hidden } ) 

**MBS**( **"XL.Sheet.SetColPx";** /\* Sets column width in pixels and format for all columns from colFirst to colLast. \*/  
**$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 \*/   
**$ColFirst**; /\* The first column.e.g. 0 \*/   
**$ColLast**; /\* The last column.e.g. 0 \*/   
**$Width**; /\* The new column width in pixels.  
Value -1 is used for autofit column widths.e.g. 100 \*/   
**$Format**; /\* Optional; The format for the cell. This is index from 0 to XL.GetFormatCount-1 in the book's list of formats.e.g. 0 \*/   
**$Hidden**) /\* Optional; Whether to hide columns.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 |  |
| ColFirst | The first column. | 0 |  |
| ColLast | The last column. | 0 |  |
| Width | The new column width in pixels.   Value -1 is used for autofit column widths. | 100 |  |
| Format | The format for the cell. This is index from 0 to XL.GetFormatCount-1 in the book's list of formats. | 0 | Optional |
| Hidden | Whether to hide columns. | 0 | Optional |

### Result

Returns OK or error message.

### Description

Sets column width in pixels and format for all columns from colFirst to colLast.   
If format equals 0 then format is ignored. Columns may be hidden.   
### Examples

Set first column to 200 pixel:

 Set Variable \[ $r ; Value: MBS ( "XL.Sheet.SetColPx"; $book ; $sheet ; 0; 0; 200) \]  
### See also

- [XL.Book.SheetCount](XLBookSheetCount.md)
- [XL.Sheet.SetColumn](XLSheetSetColumn.md)
- [XL.Sheet.SetFooter](XLSheetSetFooter.md)
- [XL.Sheet.SetMerge](XLSheetSetMerge.md)
- [XL.Sheet.SetPaper](XLSheetSetPaper.md)
- [XL.Sheet.SetRow](XLSheetSetRow.md)
- [XL.Sheet.SetRowPx](XLSheetSetRowPx.md)
- [XL.Sheet.SetRows](XLSheetSetRows.md)
- [XL.Sheet.SetTabColor](XLSheetSetTabColor.md)
- [XL.Sheet.SetZoom](XLSheetSetZoom.md)

### Release notes

- **Version 13.3**
    - Added [XL.Sheet.SetColPx](https://www.mbsplugins.eu/XLSheetSetColPx.shtml) and [XL.Sheet.SetRowPx](https://www.mbsplugins.eu/XLSheetSetRowPx.shtml) functions.

### Blog Entries

- [New in MBS FileMaker Plugin 13.3](https://www.mbsplugins.de/archive/2023-07-25/New_in_MBS_FileMaker_Plugin_13/monkeybreadsoftware_blog_filemaker)
- [Neues MBS Plugin 13.3 für Claris FileMaker](https://www.mbsplugins.de/archive/2023-07-18/Neues_MBS_Plugin_133_für_Clar/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin 13.3 for Claris FileMaker](https://www.mbsplugins.de/archive/2023-07-18/MBS_Plugin_133_for_Claris_File/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 13.3pr6](https://www.mbsplugins.de/archive/2023-07-05/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 2nd July 2023 , last changed 27th August 2023

  
[XL.Sheet.SetColHidden](XLSheetSetColHidden.md) - [XL.Sheet.SetColumn](XLSheetSetColumn.md)

[HTML Version](XLSheetSetColPx.shtml)