04 FormatFill - AndrewMB2/Logic-Architect-for-Excel-VBA GitHub Wiki
FormatFill method
Fills formats and/or validation from those in the first row of data or Source if provided. Returns True if successful, otherwise False.
Applies to
| TableData | ArrData | RsetData | Xdata | XShared |
|---|---|---|---|---|
| ✓ |
Parameters
| Name | Type | Description |
|---|---|---|
| Source | Range (optional) | Range from which formats will be copied. |
| Formats | Boolean (optional) | True (default) fills formats. |
| Validation | Boolean (optional) | True fills validation. |
| FormatConditions | Boolean (optional) | True fills conditional formats. |
FormatFill is used to format or apply validation to a TableData object after setting up the data, and is normally used when creating a report. It can be used to fill from the first row of data (if there is one) or from a separate template range. The recommended usage is to set up a template range in the row above the header row, apply all required formats, give it a name and then hide it.
Formats may include conditional formats. A common problem with conditional formats is that they become fragmented with repeated maintenance. By clearing formats from the TableData object when clearing contents, repopulating it with CopyFrom and then using FormatFill, this problem is avoided. The FormatConditions parameter should only be set when the requirement is to copy conditional formatting only and no other formatting, as conditional formatting is automatically copied when the Formats parameter is set to True.
When the TableData object has no data:
- If it is a table, formats and/or validation are applied to the row below the header row.
- Otherwise, FormatFill does nothing.