CheckingOutput

Renders IChecking diagnostic entries to a worksheet with formatted rows, severity-based colour coding, and interactive drop-down filters for status and title. The class manages hidden helper columns, a title store for filter validation lists, and optional worksheet event injection so that filter selections trigger row visibility changes automatically.

Version: 1.0 (2026-02-09)

Factory

create #

Create an output writer bound to a worksheet

Signature:

Public Function Create(ByVal sh As Worksheet, Optional ByVal title As String = vbNullString) As ICheckingOutput

Entry point for creating CheckingOutput instances. Instantiates a new writer and associates it with the supplied worksheet. Optionally assigns a title used for the end-of-checkings marker.

Parameters:

  • sh: Worksheet. Target worksheet that will receive the checking output.
  • title: Optional String. Label for the output session. Defaults to vbNullString.

Returns: ICheckingOutput. Fully initialised instance.

Throws:

  • ProjectError.ElementNotFound When sh is Nothing.

Filtering

filter-worksheet #

Apply filtering logic using the backing worksheet

Signature:

Public Sub FilterWorksheet(Optional ByVal statusSelection As String = vbNullString, _
                          Optional ByVal titleSelection As String = vbNullString)

Public entry point that allows consumers to reapply the worksheet filtering logic without relying on events. Delegates to ApplyWorksheetFilter.

Parameters:

  • statusSelection: Optional String. Manual filter selection overriding the drop-down value.
  • titleSelection: Optional String. Title filter overriding the worksheet selection.

WorksheetEvents

ensure-worksheet-change-handler #

Inject the Worksheet_Change handler into the target module

Signature:

Private Sub EnsureWorksheetChangeHandler()

Injection and generation of the Worksheet_Change handler for interactive filtering. Injects the filtering VBA code into the worksheet's code module so filter drop-down changes trigger row visibility updates automatically. Skips injection when the event marker hidden name is already present.

Throws:

  • ProjectError.SomethingWentWrong When code injection fails.

Interface

Write checking values to a worksheet

Signature:

Private Sub ICheckingOutput_PrintOutput(ByVal checkTable As BetterArray)

Coordinates the end-to-end rendering: validates the input array, initialises the worksheet, writes each checking bundle, appends the end marker, and records the final row position.

Parameters:

  • checkTable: BetterArray. Collection of IChecking instances to print.

Throws:

  • ProjectError.ElementNotFound When checkTable is Nothing.

Internal members (not exported)

PublicAccessors

wksh #

Retrieve the worksheet backing this output writer

Signature:

Public Property Get Wksh() As Worksheet

Properties that expose internal state and the interface pointer. Returns the worksheet previously supplied during Create or the setter.

Returns: Worksheet. Reference to the target worksheet.


wksh-set #

Define the worksheet that will receive the output

Signature:

Public Property Set Wksh(ByVal sh As Worksheet)

Parameters:


self #

Current object instance

Signature:

Public Property Get Self() As ICheckingOutput

Returns the current instance cast to its interface. Used internally by the factory method to return an ICheckingOutput reference.

Returns: ICheckingOutput. Reference to the current object.


name #

Name of the output session

Signature:

Public Property Get Name() As String

Returns the label assigned during creation or via the setter.

Returns: String. Output session label.


name-set #

Assign the output session name

Signature:

Public Property Let Name(ByVal nm As String)

Parameters:


FormattingHelpers

resolve-formatting #

Resolve formatting attributes for a given level and colour name

Signature:

Private Function ResolveFormatting(Optional ByVal tag As String) As TFormatting

Colour resolution, text decoration, and border styling. Maps a tag string (colour name or heading level) to font, fill, and border properties returned in a TFormatting structure.

Parameters:

Returns: TFormatting. Structure with font, fill, and border properties.


apply-text-decorations #

Apply typography styling based on formatting

Signature:

Private Sub ApplyTextDecorations(formatting As TFormatting, ByVal target As Range)

Decorates the target range with font size, colour, fill, and bold emphasis from the supplied formatting structure.

Parameters:


apply-borders #

Apply border styling to a range

Signature:

Private Sub ApplyBorders(ByVal targetRange As Range, ByVal borderColour As Long)

Applies a dashed bottom border to the target range block.

Parameters:


write-row #

Format and write a single row of checking output

Signature:

Private Sub WriteRow(ByVal rowIndex As Long, ByVal textValue As String, _
                     Optional ByVal formatTag As String, _
                     Optional ByVal sep As String = DEFAULT_SEPARATOR, _
                     Optional ByVal parentTitle As String = vbNullString)

Splits the text value by the separator and writes the fragments across the output columns. Applies formatting based on the format tag and records the parent title in the hidden column for filtering.

Parameters:


value-or-empty #

Safely retrieve an element from a split array

Signature:

Private Function ValueOrEmpty(items() As String, ByVal index As Long) As String

Returns the element at the specified index when it exists, or vbNullString when the index exceeds the array bounds.

Parameters:

Returns: String. Element value or vbNullString.


CheckingWriters

write-checking #

Write a single IChecking bundle to the worksheet

Signature:

Private Sub WriteChecking(ByVal checking As IChecking, _
                          ByRef currentRow As Long, _
                          ByRef writtenTitles As Collection, _
                          Optional ByVal sep As String = DEFAULT_SEPARATOR)

Outputs headings and detail entries for individual checking bundles. Outputs the title heading (once per unique title), optional subtitle, and all keyed entries with their severity colour coding. Advances the current row counter and tracks written titles to avoid duplicates.

Parameters:


title-already-written #

Test whether a title has already been emitted

Signature:

Private Function TitleAlreadyWritten(ByVal title As String, ByRef writtenTitles As Collection) As Boolean

Checks the writtenTitles collection for the specified title. Uses On Error Resume Next to handle missing keys.

Parameters:

Returns: Boolean. True when the title was already written.


TitleStoreManagement

ensure-title-store #

Initialise or refresh the hidden title store

Signature:

Private Sub EnsureTitleStore(Optional ByVal resetStore As Boolean = False)

Manages the hidden title store used for the title filter validation list. When resetStore is True, clears all stored titles and re-creates the anchor cell. Otherwise ensures the anchor exists and the named range is defined.

Parameters:


reset-title-store #

Clear all stored titles and re-create the anchor

Signature:

Private Sub ResetTitleStore(ByVal sh As Worksheet)

Parameters:


ensure-title-store-anchor #

Ensure the title store anchor cell is initialised

Signature:

Private Sub EnsureTitleStoreAnchor(ByVal sh As Worksheet)

Parameters:


append-title-to-store #

Add a title to the hidden store if not already present

Signature:

Private Sub AppendTitleToStore(ByVal titleValue As String)

Parameters:


title-store-contains #

Check whether the title store already includes a value

Signature:

Private Function TitleStoreContains(ByVal sh As Worksheet, ByVal titleValue As String) As Boolean

Parameters:

Returns: Boolean. True when the title is already stored.


refresh-title-named-range #

Update the named range covering all stored titles

Signature:

Private Sub RefreshTitleNamedRange(ByVal sh As Worksheet)

Parameters:


next-title-store-row #

Determine the next available row in the title store

Signature:

Private Function NextTitleStoreRow(ByVal sh As Worksheet, ByVal anchor As Range) As Long

Parameters:

Returns: Long. Next available row index.


worksheet-has-named-range #

Check whether a named range exists on a worksheet

Signature:

Private Function WorksheetHasNamedRange(ByVal targetSheet As Worksheet, ByVal rangeName As String) As Boolean

Parameters:

Returns: Boolean. True when the named range exists.


worksheet-name-for-formula #

Escape the worksheet name for use in formulas

Signature:

Private Function WorksheetNameForFormula(ByVal targetSheet As Worksheet) As String

Parameters:

Returns: String. Escaped worksheet name.


apply-hidden-columns-formatting #

Mask hidden helper columns so metadata remains invisible

Signature:

Private Sub ApplyHiddenColumnsFormatting(ByVal sh As Worksheet)

Ensures the parent-title column and backing title store column keep a white font and hidden presentation.

Parameters:


WorksheetPreparation

initialise-worksheet #

Reset the worksheet before re-rendering checking output

Signature:

Private Function InitialiseWorksheet() As Long

Resets and initialises the worksheet before rendering. On first render, clears all cells, sets the Consolas font, creates the title store, installs filter dropdowns, removes gridlines, and records the starting row marker. On subsequent renders, resumes from the last written row.

Returns: Long. Starting row for the next output block.


Filtering

ensure-filter-dropdown #

Install and style the filter drop-downs on the worksheet header

Signature:

Private Sub EnsureFilterDropdown()

Drop-down filter management and row-visibility algorithms. Creates validation drop-downs for both status (severity) and title filtering. Ensures the title store named range is available for the title validation list.


apply-worksheet-filter #

Internal helper that performs row-visibility filtering

Signature:

Private Sub ApplyWorksheetFilter(ByVal targetSheet As Worksheet, _
                                 Optional ByVal statusSelection As String = vbNullString, _
                                 Optional ByVal titleSelection As String = vbNullString)

Centralises the filtering algorithm so both the public API and worksheet events reuse the same logic. Hides rows that do not match the selected severity and/or title criteria.

Parameters:


WorksheetEvents

build-worksheet-change-handler-code #

Compose the VBA code for the worksheet filtering logic

Signature:

Private Function BuildWorksheetChangeHandlerCode() As String

Generates the complete VBA source code that is injected into the worksheet module. Includes StripIcons, ResolveMatchType, ShouldFilterByTitle, RestoreState, Worksheet_Change, and FilterCheckingOutputRows procedures.

Returns: String. VBA source code for the handler.


WorksheetEventHelpers

remove-managed-worksheet-procedures #

Strip previously injected worksheet routines

Signature:

Private Sub RemoveManagedWorksheetProcedures(ByVal codeModule As Object)

Utilities for managing injected worksheet procedures. Removes any instance of the managed procedures so a single fresh handler can be written without duplication.

Parameters:


delete-procedure-if-exists #

Safely remove a procedure from a worksheet module

Signature:

Private Sub DeleteProcedureIfExists(ByVal codeModule As Object, ByVal procedureName As String)

Deletes the target procedure when present. Silently exits when the procedure is not found.

Parameters:


Helpers

validate-check-table #

Verify that the BetterArray contains only IChecking entries

Signature:

Private Sub ValidateCheckTable(ByVal checkTable As BetterArray)

Private utility methods for validation, normalisation, and storage. Iterates the array and raises an error for any item that does not implement IChecking.

Parameters:

Throws:


normalise-type-label #

Strip icon characters from a checking type label

Signature:

Private Function NormaliseTypeLabel(ByVal typeLabel As String) As String

Removes Unicode icon characters used for visual decoration to obtain the plain-text type label for filtering comparisons.

Parameters:

Returns: String. Cleaned label.


custom-property-exists #

Check whether a custom property exists in the hidden store

Signature:

Private Function CustomPropertyExists(ByVal propName As String) As Boolean

Parameters:

Returns: Boolean. True when the property exists.


store-custom-property #

Store a custom property in the hidden name store

Signature:

Private Sub StoreCustomProperty(propName As String, propValue As String)

Parameters:


hidden-store #

Lazily create and return the IHiddenNames store

Signature:

Private Function HiddenStore() As IHiddenNames

Creates the HiddenNames wrapper bound to the target worksheet on first access. Raises an error when no worksheet is assigned.

Returns: IHiddenNames. Hidden name store.

Throws:


module-contains-procedure #

Determine whether the module text declares a target procedure

Signature:

Private Function ModuleContainsProcedure(ByVal moduleText As String, _
                                         ByVal procedureName As String) As Boolean

Searches for Sub or Function signatures matching the procedure name.

Parameters:

Returns: Boolean. True when the procedure exists.


ErrorHandling

throw-error #

Raise a ProjectError-coded runtime error

Signature:

Private Sub ThrowError(ByVal errNumb As Long, ByVal errorMessage As String)

Centralised error-raising pattern. Wrapper around Err.Raise that standardises the source to "CheckingOutput" for consistent stack traces.

Parameters:

Throws:


Interface

ICheckingOutput_Wksh #

Signature:

Private Property Get ICheckingOutput_Wksh() As Worksheet

Delegated members satisfying the ICheckingOutput contract.


Used in (6 file(s))