I've inherited an old Excel-VBA model at work. I'm running this program to calculate loss on a portfolio of loans. The program works fine for a loan portfolio up to 500 loan items, but starts throwing up "Run-Time Error Type '13' mismatch" when I load a larger portfolio with more than 500 items.

Code:
    Public Sub generateLossDistribution()

    ....

        Dim i As Long, j As Long
        Dim p As portfolio
        ' Creates a new portfolio object and reads it
        **Set p = New portfolio**
The error message crops up in the "**" code line. FYI, "portfolio" is a user defined object/class module. Since the code works for fewer loan items, could this error be due to increased array size (when bigger portfolio gets loaded)? The portfolio has about 30 fields for each loan items. Is there a limit on the array size, which I can expand?

Apologies of being very vague since I'm just a beginner and the model code is too huge to be uploaded to make any sense.

Thanks