+ Reply to Thread
Results 1 to 7 of 7

Getting: could not get List property. Invalid argument error

Hybrid View

sniper1 Getting: could not get List... 06-09-2020, 04:50 PM
AlphaFrog Re: Getting: could not get... 06-09-2020, 09:47 PM
Andy Pope Re: Getting: could not get... 06-10-2020, 03:16 AM
Sintek Re: Getting: could not get... 06-10-2020, 04:59 AM
sniper1 Re: Getting: could not get... 06-10-2020, 08:53 AM
torachan Re: Getting: could not get... 06-10-2020, 09:01 AM
sniper1 Re: Getting: could not get... 06-11-2020, 05:25 AM
  1. #1
    Registered User
    Join Date
    04-24-2020
    Location
    USA
    MS-Off Ver
    WA
    Posts
    64

    Getting: could not get List property. Invalid argument error

    I ran into an error that I think had something to do with list index. I have tried to debug and fix it, but continue to have the same error. Issue: when I click the item in the listbox, I want them to populate the textboxes, but they are in a way, but with this error. Any help is very much appreciated.

    Thank you!
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Getting: could not get List property. Invalid argument error

    "A VBA ListBox will not display more than 10 columns of data unless you link the ListBox to Range using the "RowSource" property."

    Private Sub lstTools_Click()
        
        With lstTools
            txtDept = .List(.ListIndex, 0)
            txtTools = .List(.ListIndex, 1)
            txtStatus = .List(.ListIndex, 2)
            txtDateRet = .List(.ListIndex, 3)
            txtRetBy = .List(.ListIndex, 4)
            txtActive = .List(.ListIndex, 5)
            txtMT = .List(.ListIndex, 6)
            txtInspBy = .List(.ListIndex, 7)
            txtVerBy = .List(.ListIndex, 8)
            txtDateInsp = .List(.ListIndex, 9)
            txtDateVer = .List(.ListIndex, 10)
            txtDamaged = .List(.ListIndex, 11)
            txtComments = .List(.ListIndex, 12)
        End With
        
    End Sub
    
    Private Sub UserForm_Initialize()
        Dim mysheet As Worksheet, lastrow As Long
        
        Set mysheet = ThisWorkbook.Sheets("Tracker")
        
        lastrow = mysheet.Cells(Rows.Count, 1).End(xlUp).Row
        
        Me.lstTools.ColumnCount = 13
        Me.lstTools.ColumnWidths = "50;50;30;60;50;30;50;50;50;50;50;50;200"
        
        Me.lstTools.RowSource = mysheet.Range("A2:M" & lastrow).Address(External:=True)
        
    End Sub
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Getting: could not get List property. Invalid argument error

    You can also load more than 11 columns by loading the List from an array.

    Private Sub UserForm_Initialize()
        Dim mysheet As Worksheet
        Dim listData As Variant
        
        Set mysheet = ThisWorkbook.Sheets("Tracker")
        
        lastrow = mysheet.Cells(Rows.Count, 1).End(xlUp).Row
        'For Each cell In [cboList]
        '  Me.cboStatus.AddItem cell
        'Next cell
        
        listData = mysheet.Cells(2, 1).Resize(lastrow - 2 + 1, 13)
        Me.lstTools.ColumnCount = 13
        Me.lstTools.List = listData
        
        With Me
            Width = Application.Width * 0.5
            Height = Application.Height * 0.6
        End With
        'For Each x In [TList]
        '    Me.cmbTools.AddItem x
        'Next x
    
    End Sub
    Cheers
    Andy
    www.andypope.info

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Getting: could not get List property. Invalid argument error

    Or...
    Private Sub UserForm_Initialize()
    Dim Arr
    Arr = Sheets("Tracker").ListObjects(1).DataBodyRange.Value
    With Me.lstTools
        .ColumnCount = 13
        .ColumnWidths = "40;40;40;40;40;40;40;40;40;40;40;40;40"
        .List = Arr
    End With
    End Sub
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  5. #5
    Registered User
    Join Date
    04-24-2020
    Location
    USA
    MS-Off Ver
    WA
    Posts
    64

    Re: Getting: could not get List property. Invalid argument error

    Gentlemen,

    Your assistance, all of them are on point! Thank you!

  6. #6
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,410

    Re: Getting: could not get List property. Invalid argument error

    As per last post, you have placed your data in a table, therefore use table referencing throughout your app.
    Makes for simpler coding, also use simple tricks to condense your coding, loop through a set of TextBoxes instead of naming each.
    Use your table headers to populate the UserForm Label captions - repetitive code (ClearForm & LoadListBox) program once in a module and call as appropriate.
    I have popped a couple of comboboxes behind second and third textboxes loaded with choices from your other tables(status & tools) the are held in position by applying the ZOrder.
    Example attached utilizing your app. Hope of some assistance.
    torachan.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    04-24-2020
    Location
    USA
    MS-Off Ver
    WA
    Posts
    64

    Re: Getting: could not get List property. Invalid argument error

    Awesome! Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] could not get the list property invalid argument - VBA Error code
    By chrismccarthy17 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-02-2016, 11:23 AM
  2. runtimer error 380, could not set the list the list property, Invalid property type
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-11-2015, 12:19 PM
  3. [SOLVED] Getting compile error 'Wrong number of argument or invalid property assignment'
    By mso3 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-17-2014, 07:50 AM
  4. Runtime error 381: Could not set the list property.Invalid property array index
    By rohith4prithvi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-23-2014, 10:24 PM
  5. [SOLVED] Excel run-time error '381': Could not set the List property. Invalid property array index
    By eemiller1997 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-20-2012, 12:48 PM
  6. Replies: 3
    Last Post: 04-28-2010, 05:54 PM
  7. Error: Wrong number of argument or invalid property assignment?
    By Mike in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-11-2006, 01:35 PM

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