Padawan
Padawan

Reputation: 382

Run Time Error 13: Type Mismatch on combo Box - Excel VBA

Introduction: I have prior experience in programming (C, C++, Java), however, this is my first time using Excel VBA.

Some background: I am trying to initialize a combo box with a list from a sheet called ORI_LIST but every time I run it I get Run Time Error 13. Any information on this would be great.

Private Sub UserForm_Initialize()
    Dim cLoc As Range
    Dim OriSheetList As Worksheets

    Set OriSheetList = Worksheets("ORI_LIST")

    For Each cLoc In OriSheetList.Range("CRI")
        With Me.COMBO_ORILIST
            .AddItem cLoc.Value
        End With
    Next cLoc
End Sub

Upvotes: 1

Views: 2358

Answers (1)

Brad
Brad

Reputation: 12253

Ah this is a silly one but you want Dim OriSheetList As Worksheet.

The Worksheet object is singular. The collection of all the sheets in the workbook is plural. It would be nice if there was a little more help from the IDE on these issues but alas that is the world of VBA.

Upvotes: 2

Related Questions