XL.Format.SetPatternBackgroundColor
-----------------------------------

Sets the background color of the fill pattern.

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

MBS( "XL.Format.SetPatternBackgroundColor"; Book; Format; Value ) 

**MBS**( **"XL.Format.SetPatternBackgroundColor";** /\* Sets the background color of the fill pattern. \*/  
**$Book**; /\* The reference number for the workbook.e.g. $ref \*/   
**$Format**; /\* The index of the format in the book to target.e.g. 0 \*/   
**$Value**) /\* The new setting. \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Book | The reference number for the workbook. | $ref |
| Format | The index of the format in the book to target. | 0 |
| Value | The new setting. | $value |

### Result

Returns OK or error.

### Description

Sets the background color of the fill pattern.  
If you set value and book is in RGB mode you can use XL.ColorPack function to get a numeric value for color components. If the book is not in RGB mode, you can use color values as described in [XL.Font.SetColor](XLFontSetColor.md).  
  
This is the background color for the pattern, you can put in the background of a cell. If your pattern is stripes, the one color is the foreground one and the other the background one.  
### Examples

Sets the fore color to red:

 If \[ MBS ( "[XL.Book.GetRGBMode](XLBookGetRGBMode.md)"; $book ) = 0 \]  
 Set Variable \[ $r ; Value: MBS ( "XL.Format.SetPatternBackgroundColor"; $book ; $format ; 10) \]   
Else  
 Set Variable \[ $c ; Value: MBS ( "[XL.Color.Pack](XLColorPack.md)"; $book ; 255; 0; 0) \]  
 Set Variable \[ $r ; Value: MBS ( "XL.Format.SetPatternBackgroundColor"; $book ; $format ; $c ) \]   
End If  
Set Variable \[ $r ; Value: MBS ( "[XL.Format.SetFillPattern](XLFormatSetFillPattern.md)"; $book ; $format ; 1 ) \]  
Create a 75% gray pattern with blue and red dots:

 # make sure we have RGB mode   
Set Variable \[ $r ; Value: MBS ( "[XL.Book.SetRGBMode](XLBookSetRGBMode.md)"; $book ; 1 ) \]   
\#   
\# Define new format   
Set Variable \[ $format ; Value: MBS ( "[XL.Book.AddFormat](XLBookAddFormat.md)"; $book ) \]   
\#   
\# Encode some RGB colors   
Set Variable \[ $redcolor ; Value: MBS ( "[XL.Color.Pack](XLColorPack.md)"; $book ; 255; 0; 0) \]   
Set Variable \[ $bluecolor ; Value: MBS ( "[XL.Color.Pack](XLColorPack.md)"; $book ; 0; 0; 255) \]   
\#   
\# set colors for pattern   
Set Variable \[ $r ; Value: MBS ( "[XL.Format.SetPatternForegroundColor](XLFormatSetPatternForegroundColor.md)"; $book ; $format ; $redcolor ) \]   
Set Variable \[ $r ; Value: MBS ( "XL.Format.SetPatternBackgroundColor"; $book ; $format ; $bluecolor ) \]   
\#   
\# and have this format fill the pattern   
Set Variable \[ $r ; Value: MBS ( "[XL.Format.SetFillPattern](XLFormatSetFillPattern.md)"; $book ; $format ; 3 ) // 75% gray \]  
### See also

- [XL.Book.AddFormat](XLBookAddFormat.md)
- [XL.Book.GetRGBMode](XLBookGetRGBMode.md)
- [XL.Book.SetRGBMode](XLBookSetRGBMode.md)
- [XL.Color.Pack](XLColorPack.md)
- [XL.Font.SetColor](XLFontSetColor.md)
- [XL.Format.GetPatternBackgroundColor](XLFormatGetPatternBackgroundColor.md)
- [XL.Format.GetPatternForegroundColor](XLFormatGetPatternForegroundColor.md)
- [XL.Format.SetFillPattern](XLFormatSetFillPattern.md)
- [XL.Format.SetPatternForegroundColor](XLFormatSetPatternForegroundColor.md)

This function checks for a license.

Created 18th August 2014 , last changed 2nd November 2021

  
[XL.Format.SetNumFormat](XLFormatSetNumFormat.md) - [XL.Format.SetPatternForegroundColor](XLFormatSetPatternForegroundColor.md)

[HTML Version](XLFormatSetPatternBackgroundColor.shtml)