LLChoices

Manages worksheet-based choice lists used for dropdowns and cascading selectors. Each choice is identified by a list name and carries long labels, short labels, and an ordering column. Built on top of a DataSheet for column-oriented data access.

Depends on: DataSheet, CustomTable, Checking, BetterArray, ITranslationObject

Version: 1.0 (2026-02-09)

Factory

create #

Create a new LLChoices instance

Signature:

Public Function Create(ByVal choiceWorksheet As Worksheet, _ 
                       ByVal choiceStartRow As Long, _
                       ByVal choiceStartColumn As Long, _ 
                       Optional ByVal choiceName As String = vbNullString) As _ 

Wraps the given worksheet in a DataSheet and returns a configured ILLChoices instance. The default headers are "list name", "label", "short label", and "ordering list".

Parameters:

  • choiceWorksheet: Worksheet. The worksheet hosting the choices.
  • choiceStartRow: Long. First row of choice data.
  • choiceStartColumn: Long. First column of choice data.
  • choiceName: Optional String. Name for the choice object. Defaults to vbNullString.

Returns: ILLChoices. The new instance.


Elements

choice-data #

Associated DataSheet object

Signature:

Public Property Get ChoiceData() As IDataSheet

Returns: IDataSheet. The backing DataSheet.


wksh #

Worksheet hosting the choice lists

Signature:

Public Property Get Wksh() As Worksheet

Returns: Worksheet. The host worksheet.


Choices

name #

Name of the choice object

Signature:

Public Property Get Name() As String

Returns: String. The choice object name.


choice-exists #

Check whether a choice exists

Signature:

Private Property Get ChoiceExists(ByVal choiceName As String) As Boolean

Parameters:

  • choiceName: String. Choice name to search for.

Returns: Boolean. True when the choice is found.


sort #

Sort choices in the worksheet

Signature:

Private Sub Sort()

add-choice #

Add a new choice with its categories

Signature:

Private Sub AddChoice(ByVal choiceName As String, _
                      ByVal longLabelData As BetterArray, _ 
                      Optional ByVal shortLabelData As Object = Nothing)

Appends a new choice entry with long labels and optional short labels. Silently exits when the choice already exists or the data is empty.

Parameters:

  • choiceName: String. Name of the choice to add.
  • longLabelData: BetterArray. Long label values for the categories.
  • shortLabelData: Optional Object. BetterArray of short label values. Defaults to Nothing.

remove-choice #

Remove one or multiple choices

Signature:

Private Sub RemoveChoice(Byval choiceNames As String, Optional ByVal sep As String = ";")

Parameters:

  • choiceNames: String. Choice names separated by sep.
  • sep: Optional String. Delimiter. Defaults to ";".

translate #

Translate the choice worksheet labels

Signature:

Private Sub Translate(ByVal trads As ITranslationObject)

Parameters:

  • trads: ITranslationObject. Translation provider.

manage-rows #

Add or remove rows via a single toggle

Signature:

Private Sub ManageRows(Optional ByVal del As Boolean = False)

Parameters:

  • del: Optional Boolean. When True, removes rows. Defaults to False.

add-rows #

Add rows to the choice table

Signature:

Private Sub AddRows()

insert-rows #

Insert rows at the selected position

Signature:

Private Sub InsertRows(ByVal targetCell As Range, _
                       Optional ByVal insertShift As Boolean = False)

Mirrors the selection height inside the choices ListObject. When the selection is invalid the attempt is logged and ignored.

Parameters:

  • targetCell: Range. Selection anchoring the insertion point.
  • insertShift: Optional Boolean. When True, inserts worksheet rows. Defaults to False.

delete-rows #

Delete rows intersecting the selection

Signature:

Private Sub DeleteRows(ByVal targetCell As Range, _
                       Optional ByVal includeIds As Boolean = True, _
                       Optional ByVal forceShift As Boolean = False)

Parameters:

  • targetCell: Range. Selection identifying rows to delete.
  • includeIds: Optional Boolean. When True, renumbers the ID column. Defaults to True.
  • forceShift: Optional Boolean. When True, forces worksheet row deletion. Defaults to False.

remove-rows #

Remove empty rows from the choice table

Signature:

Private Sub RemoveRows()

all-choices #

All distinct choice names

Signature:

Private Property Get AllChoices() As BetterArray

Returns: BetterArray. The distinct choice names.


Categories

categories #

Categories of a choice

Signature:

Public Property Get Categories(ByVal choiceName As String, _
                               Optional ByVal useShortlabels As Boolean = False) _ 

Returns the long label categories for the specified choice. When useShortlabels is True, short labels replace long labels where available. Falls back to long labels for missing short entries.

Parameters:

  • choiceName: String. The choice to retrieve categories from.
  • useShortlabels: Optional Boolean. When True, uses short labels. Defaults to False.

Returns: BetterArray. The category values.


concatenate-categories #

Concatenate all categories of a choice

Signature:

Private Property Get ConcatenateCategories( _
        ByVal choiceName As String, _ 
        Optional ByVal sep As String = " | ", _
        Optional ByVal trads As Object = Nothing) As String

Joins the categories with a separator. Optionally translates each category via the supplied TranslationObject.

Parameters:

  • choiceName: String. The choice whose categories to concatenate.
  • sep: Optional String. Separator. Defaults to " | ".
  • trads: Optional Object. A TranslationObject. Defaults to Nothing.

Returns: String. The concatenated categories.


DataExchange

add-headers #

Write the default headers to the choice worksheet

Signature:

Private Sub AddHeaders()

Writes the four standard column headers (list name, ordering, long label, short label) starting at the configured origin cell.


export #

Export the current choice object to a workbook

Signature:

Private Sub Export(ByVal Wkb As Workbook, Optional ByVal Hide As Long = xlSheetHidden)

Delegates to DataSheet.Export, including hidden names.

Parameters:

  • Wkb: Workbook. Destination workbook.
  • Hide: Long. Worksheet visibility constant. Defaults to xlSheetHidden.

import #

Import choices from a worksheet

Signature:

Private Sub Import(ByVal fromWksh As Worksheet, _
                   ByVal fromStartRow As Long, _
                   ByVal fromStartcol As Long, _ 
                   Optional ByVal clearSheet As Boolean = False)

Optionally clears the sheet and rewrites headers before importing. Creates a temporary DataSheet from the source range and delegates to DataSheet.Import.

Parameters:

  • fromWksh: Worksheet. Source worksheet containing choices.
  • fromStartRow: Long. First data row in the source.
  • fromStartcol: Long. First data column in the source.
  • clearSheet: Boolean. When True, clears the sheet before import. Defaults to False.

import-choice #

Import choices from another ILLChoices object

Signature:

Private Sub ImportChoice(ByVal choiObj As ILLChoices)

Iterates all choices in the source object, retrieves both long and short label categories, and adds each choice via AddChoice.

Parameters:

  • choiObj: ILLChoices. Source choice object to import from.

Checkings

has-checkings #

Whether the choice object has logged diagnostic messages

Signature:

Private Property Get HasCheckings() As Boolean

Returns: Boolean. True when diagnostic entries exist.


checking-values #

Retrieve the diagnostic log entries

Signature:

Private Property Get CheckingValues() As Object

Returns the internal IChecking object containing all logged messages. Returns Nothing when no entries have been recorded.

Returns: Object. An IChecking instance, or Nothing.


Internal members (not exported)

Factory

choice-label #

Resolve the label column name

Signature:

Private Property Get ChoiceLabel(Optional ByVal keepDefault As Boolean = True) As String

Returns the translated label column when available, otherwise falls back to the default label column.

Parameters:

Returns: String. The resolved column name.


Elements

choice-data-set #

Assign the backing DataSheet

Signature:

Public Property Set ChoiceData(ByVal customDataSheet As IDataSheet)

Parameters:


start-row #

First row of choice data

Signature:

Public Property Get StartRow() As Long

Returns: Long. The start row.


start-column #

First column of choice data

Signature:

Public Property Get StartColumn() As Long

Returns: Long. The start column.


data-range #

Data range from the backing DataSheet

Signature:

Private Property Get DataRange( _ 
    Optional ByVal colName As String = "__all__", _
    Optional ByVal includeHeaders As Boolean = True) As Range

Parameters:


Validation

has-valid-headers #

Check whether all required headers exist

Signature:

Private Property Get HasValidHeaders() As Boolean

Returns: Boolean. True when all four required columns are found.


Choices

name-set #

Assign the choice object name

Signature:

Public Property Let Name(ByVal choiceName As String)

Parameters:


remove-one-choice #

Remove a single choice by name

Signature:

Private Sub RemoveOneChoice(ByVal choiceName As String)

Parameters:


resolve-row-target #

Validate a selection and resolve its ListObject

Signature:

Private Function ResolveRowTarget(ByVal targetCell As Range, ByVal actionLabel As String) As ListObject

Parameters:

Returns: ListObject. The ListObject, or Nothing when invalid.


Checkings

log-info #

Append a diagnostic entry to the internal checking object

Signature:

Private Sub LogInfo(ByVal label As String, _ 
                    Optional ByVal scope As Byte = checkingNote)

Lazily creates the Checking instance on first call. Increments the internal counter used as the entry key.

Parameters:


show-debug #

Print diagnostic summary to the Immediate window

Signature:

Private Sub ShowDebug()

Used in (26 file(s))