How to Clear value a listbox!

  • Thread starter Thread starter bookworm98
  • Start date Start date
B

bookworm98

Can anyone know the way to set a ListBox(Form) empty.
With the TextBox and Combox the Text property can read and write.
But with the ListBox i think it only can read?
Is there any way?
 
Is this something that you want ... ? This initialises a 2 column lis
box :-

'- initialise form
Private Sub UserForm_Initialize()
Set DataSheet = ThisWorkbook.Worksheets("data")
Set MyList = DataSheet.Range("FileList")
Rw = 1
FileListBox.Clear
While MyList.Cells(Rw, 1).Value <> ""
FileListBox.AddItem
FileListBox.List(Rw - 1, 0) = MyList.Cells(Rw, 1).Value
FileListBox.List(Rw - 1, 1) = MyList.Cells(Rw, 2).Value
Rw = Rw + 1
Wend
End Su
 
Did you want to unselect any selected items, or did you want to remove
all the items showing in the listbox?

If the former, just use ListBox1.ListIndex = -1

If the latter, does your listbox have a rowsource, or is it populated
with AddItem?
 
What I mean is:
If I have a listbox1 which has a property List Range: A1:A3
A1="";
A2="1";
A3="2"; for example;
The list box I resize it into one row(Which will has up and dow
buttons). Assume I used down button to choose the value 2(A3).
How can I set listbox1 appear blank.
I can use:
ListBox1.ListIndex = 0;
But it only affect when the ListBox1 is selected!
Help me
 
Listbox.ListIndex = -1
Listbox.TopIndex = 0
would show what is in cell A1 (which is blank). I believe that is what you
mean.
 
Back
Top