Thursday, May 22, 2014

Error: Only user defined types defined in public object modules can be coerced to or from a variant or passed to late bound functions

The error box

Highlighed code

arrAccrControl(UBound(arrAccrControl)) _

Other side of the "=" sign

wsAccSummControl.Range(TKAccruals_IDColLtr & i).Value

Definition of highlighted code

Dim arrAccrControl() As AccrualsWorkBook

Definition of AccrualsWorkBook

Function AccrualsWorkBook(ScopeMonth As Date, _
                            Prog As ClientProgram, _
                            Optional WkBkStatus) As Workbook

Public Type AccrualsWorkBook
        ProgramGroup     As String
        HasSummarySheet  As Boolean
        StartDate       As Date
        EndDate         As Date
End Type

The research...

When I searched for an explanation on the web I found a lot of references to things I wasn't doing, mainly using a Collection.

The Solution...The real Solution...

Did not have the field in the data structure 
    arrAccrControl(UBound(arrAccrControl)).ProgramGroup     _