ListBox Remove Certain Text
On Nov 27, 4:20*am, Per Jessen wrote:
HI
Try this:
Private Sub UserForm_Initialize()
Dim ListRng As Range
ListBox1.ColumnCount = 3
For Each cell In Range("Stu_Data_List")
* * If cell.Column = 2 And cell < "Prospect" Then
* * * * If ListRng Is Nothing Then
* * * * * * Set ListRng = Range("Stu_Data_List").Rows(1)
* * * * Else
* * * * * * Set ListRng = Union(ListRng,
Range("Stu_Data_List").Rows(cell.Row))
* * * * End If
* * End If
Next
ListBox1.RowSource = ListRng.Parent.Name & "!" & ListRng.Address
End Sub
Regards,
Per
On 26 Nov., 17:06, Darrell Lankford wrote:
Does anyone know a code to fill a ListBox so that the cells with the
specific text don’t show up in the ListBox? Below is the basic code
that enters a list of students in the list box with their ID# and I
want the ones in Column "B" to not show in the ListBox that are
identified as "Prospect". Any help would be greatly appreciated.
Code
* * ListBox1.ColumnCount = 3
* * ListBox1.RowSource = "Stu_Data_List"
Worksheet
Column B * * Column C * * Column D
* *ID# * * * * Last Name * * First Name
* *SM001 * * *Smith * * * * * *John *(Show in Listbox)
* *JO001 * * * Jones * * * * * Kelly *(Show in Listbox)
* Prospect * *Bailey * * * * * *Bill * (Not Show in Listbox)- Hide quoted text -
- Show quoted text -
Code as is gives me Runtime Error 380 "Could not set the rowsource
property. Invalid property value." I tried changing my ranges and
changing up the code a little and I get Runtime Error 91 "Object
variable or with block variable not set."
|