ListBox to repopulate when textbox change

raven1124

New Member
Joined
Jun 13, 2017
Messages
29
Hello everyone,

I'd like to seek for everyone's assistance why am I getting this error message:
"Could not set the list property. Invalid property value error"

I have no problem with populating the listbox1 inside a form using the code below but whenever I try to modify the listbox, the said error is happening.

Initialize
Code:
UserForm_Initialize()
    Dim x As Integer
    y = 3
    Do Until Sheets("List").Cells(y, 1) = ""
    y = y + 1
    Loop
    
    y = y - 1


    UsrReport.ListBox1.ColumnWidths = "50;120;85"
    
    For x = 3 To y
    
        With UsrReport.ListBox1
            .AddItem
            .List(x - 3, 0) = Sheet2.Cells(x, 1)
            .List(x - 3, 1) = Sheet2.Cells(x, 3) & ", " & Sheet2.Cells(x, 2)
            .List(x - 3, 2) = Sheet2.Cells(x, 5)
            .List(x - 3, 3) = Sheet2.Cells(x, 6)
        End With
    
    Next x
End Sub

Textbox Change
Code:
Sub cbJobGrade_Change()

UsrReport.ListBox1.Clear


    For x = 3 To y
        
        If Sheet2.Cells(x, 6).Value = UsrReport.cbJobGrade.Value Then
        
            With UsrReport.ListBox1
                .AddItem
                .List(x - 3, 0) = Sheet2.Cells(x, 1)
                .List(x - 3, 1) = Sheet2.Cells(x, 3) & ", " & Sheet2.Cells(x, 2)
                .List(x - 3, 2) = Sheet2.Cells(x, 5)
                .List(x - 3, 3) = Sheet2.Cells(x, 6)
            End With
            
        Else
        
        End If
        
    Next x

End Sub

Any insight is appreciated.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
In your first script you have:
y = 3

But in your second script you do not define y
I would think you need
y=3 in your second script also.
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,376
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top