+ Reply to Thread
Results 1 to 5 of 5

Runtime Error 380 - Could not set the Property Value. Invalid Property Value

  1. #1
    Registered User
    Join Date
    03-29-2021
    Location
    Arima Trinidad
    MS-Off Ver
    MS 2013
    Posts
    1

    Runtime Error 380 - Could not set the Property Value. Invalid Property Value

    I am using a simple code to run a game for my students and I am getting an error. I'm not certain what the issue is as I have the same code on another slide and it works.

    Private Sub CommandButton21_()
    ComboBox21.Visible = False
    ComboBox22.Visible = False
    ComboBox23.Visible = False

    With ComboBox21
    .Clear
    .AddItem "What………you do everyday?", 1
    .AddItem "Where………she go yesterday?", 2
    .AddItem "Why…………she go in for the tennis this year?", 3
    .AddItem "Whom……you send the email to yesterday?", 4
    .AddItem "What day………….they go to the gym?", 5
    .AddItem "Whom…………you usually help?", 6
    .AddItem "Whose book……….you take yesterday?", 7
    .AddItem "What time…………….she usually come home?", 8
    .AddItem "How long………they train last year?", 9
    .AddItem "What book………he read everyday?", 10
    .AddItem "Where…….you often go in the evening?", 11
    .AddItem "Where………they come from 2 years ago?", 12
    .AddItem "What subjects……he excel at?", 13
    .AddItem "What subject……you like last year?", 14
    End With

    With ComboBox22
    .Clear
    .AddItem "do", 1
    .AddItem "did", 2
    .AddItem "did", 3
    .AddItem "did", 4
    .AddItem "do", 5
    .AddItem "do", 6
    .AddItem "did", 7
    .AddItem "does", 8
    .AddItem "did", 9
    .AddItem "does", 10
    .AddItem "do", 11
    .AddItem "did", 12
    .AddItem "does", 13
    .AddItem "did", 14
    End With

    End Sub

    Private Sub CommandButton22_Click()

    For k = 1 To 14
    ComboBox21.ListIndex = k .....(debug error shows up here)
    ComboBox22.ListIndex = k

    If yourresponse = ComboBox22 Then
    MsgBox "Awesome"

    Else
    MsgBox "Try again"
    End If


    Next k


    End Sub

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

    Re: Runtime Error 380 - Could not set the Property Value. Invalid Property Value

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)





    Listbox lists are zero based. Yours has 14 items so your loop should go 0 to 13.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    10-13-2022
    Location
    Russia
    MS-Off Ver
    Epuloky
    Posts
    1

    -

    Thanks for your help, Dan and Ste

    I ended up using the text rule –it works beautifully. It never crossed my mind to handle it that way. Thanks again

  4. #4
    Registered User
    Join Date
    10-27-2023
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    11

    Re: Runtime Error 380 - Could not set the Property Value. Invalid Property Value

    The error in your code occurs because the ListIndex property of the ComboBox control expects an integer value, but you are attempting to assign a value from k, which is not an integer. You should set the ListIndex using an integer index that corresponds to the item you want to select in the ComboBox. Here's a corrected version of your code:

    Please Login or Register  to view this content.

    Here, I've made the following changes:

    Removed the unnecessary assignment of k to ComboBox22.ListIndex.
    Stored the selected value from ComboBox22 in the yourresponse variable and compared it to the value in the loop.
    Fixed the typo in Private Sub CommandButton21_Click() (changed CommandButton21_ to CommandButton21_Click()).


    Thanks
    Last edited by AliGW; 10-30-2023 at 07:16 AM. Reason: Code tags corrected.
    Thanks
    James

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2407 (Windows 11 23H2 64-bit)
    Posts
    84,036

    Re: Runtime Error 380 - Could not set the Property Value. Invalid Property Value

    Kind of you, however the thread was started and abandoned two and a half years ago.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ 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] Error 381Could not set the List property. Invalid property array index
    By desonny in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-16-2020, 08:33 AM
  2. Runtime Error 380 - Could not set the Property Value. Invalid Property Value
    By natks78 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-02-2015, 10:51 PM
  3. 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
  4. Run-time Error '380': Could not set the RowSource property. Invalid property value
    By Rem0ram in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-26-2013, 03:57 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: 2
    Last Post: 06-24-2010, 01:57 AM
  7. Runtime Error 380 – Could not set the list property. Invalid property value
    By BernzG in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-21-2005, 05:10 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