Results 1 to 3 of 3

Excel 2013 ListView Run-Time error '13', type mismatch

Threaded View

  1. #1
    Registered User
    Join Date
    03-18-2014
    Location
    Mississauga
    MS-Off Ver
    Excel 2013
    Posts
    5

    Excel 2013 ListView Run-Time error '13', type mismatch

    I've added this code to my worksheet as a test, it worked fine on the sample workbook, but when I run the same code in my production workbook I get an error. The userform and listview were duplicated in the prod workbook. I did notice that when I try to manually add a Listview control v6.0 to the userform, I get a blank. When I try clicking on where the listview should be in the userform I get a Library not registered error. I have scrubbed most of the VBA code and userforms from the attached file "LISTVIEW NOT WORKING.xlsm" so you can compare the 2 spreadsheets (they should be the same, but one works and the other does not).

    Private Sub LoadListView()
    
        'Declare the variables
        Dim wksSource As Worksheet
        Dim rngData As Range
        Dim rngCell As Range
        Dim LstItem As ListItem
        Dim RowCount As Long
        Dim ColCount As Long
        Dim i As Long
        Dim j As Long
        
        'Set the source worksheet
        Set wksSource = Worksheets("THistory")
        
        'Set the source range
        Set rngData = wksSource.Range("A1").CurrentRegion
        
        'Add the column headers
        For Each rngCell In rngData.Rows(1).Cells
            Form3.ListView1.ColumnHeaders.Add Text:=rngCell.Value, Width:=90
        Next rngCell
        
        'Count the number of rows in the source range
        RowCount = rngData.Rows.Count
        
        'Count the number of columns in the source range
        ColCount = rngData.Columns.Count
        
        'Fill the ListView
        For i = 2 To RowCount
            Set LstItem = Form3.ListView1.ListItems.Add(Text:=rngData(i, 1).Value) ' THIS IS WHERE I GET THE ERROR!!!
            'LstItem.ForeColor = vbBlue
            For j = 2 To ColCount
                'LstItem.ForeColor = vbRed
                LstItem.ListSubItems.Add Text:=rngData(i, j).Value
            Next j
        Next i
        
    End Sub
    Attached Files Attached Files
    Last edited by PerryBeatty; 03-19-2014 at 07:12 AM. Reason: Marked the CODE

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Excel VBA Run-time error '13' Type mismatch
    By pankajpm in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-27-2013, 05:34 AM
  2. [SOLVED] Excel VBA Run-time error '13' Type mismatch
    By mackypogi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-17-2013, 02:15 AM
  3. Excel VBA Run-time error '13' Type mismatch
    By edgaryp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-01-2013, 06:48 PM
  4. Type mismatch Error observer in Excel 2013
    By mechbhaskar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-29-2013, 07:50 AM
  5. [SOLVED] Excel VBA Frustrating Run-time error '13' Type mismatch
    By shastamccloud in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-08-2010, 02:34 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1