sharky12345
Well-known Member
- Joined
- Aug 5, 2010
- Messages
- 3,418
- Office Version
- 2016
- Platform
- Windows
I have a Listbox on a userform and I need to remove a specific value if found.
The value is in a cell, F2, and the Listbox is populdated like this;
If tried this but it doesn't remove the value;
Can someone help me understand why it doesn't work?
The value is in a cell, F2, and the Listbox is populdated like this;
VBA Code:
Set ws = Worksheets("NOMINAL ROLL")
For i = 2 To ws.Cells(ws.Rows.Count, 1).End(xlUp).Row Step 1
If ws.Cells(i, 1).Value <> vbNullString Then ListStaff1.AddItem ws.Cells(i, 1).Value
Next i
If tried this but it doesn't remove the value;
VBA Code:
Staff = Sheets("REVIEWS").Range("F2").Text
With Me.ListStaff1
For i = 0 To .ListCount - 1
If .List(i, 1) = Staff Then
.RemoveItem i
Exit For
End If
Next
End With
Can someone help me understand why it doesn't work?