View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default remove items from listbox together with add item

I don't understand.

It looks like you initially populate the listbox based on some date. So why
can't you clear that listbox based on a change to a combobox and loop again
through the range, but this time, look at the date and time?

" wrote:

On Sep 22, 9:00 pm, Dave Peterson wrote:
Instead of adding and deleting, could you just clear the listbox and add what
you want.

It might make it simpler.



" wrote:

Hi ,
I try to create a user form which contains 1 listbox and i wrote a
code to add items to a list box which only entered today. But I want
also consider hours for those entry.So lets say if for today user can
also able to choose time frame(like from14:00 to 16:00 etc).I am only
thinking to add the items for that date then remove those items which
are not in that time frame. But I really stuck. Can any one give me a
hand or give me suggestions. my code for now as follows
By the way that code only for commandbutton, All the names set.
Private Sub UserForm_Initialize()
Set reqd = ThisWorkbook.Names("req").RefersToRange
End Sub
sub GetTheList()
Dim Cell As Range
Dim trddate As Variant
trddate = Date
For Each Cell In reqd.Columns(1).Cells
If Cell.Value = trddate Then
UserForm1.ListBox1.AddItem Cell.Offset(0, 1).Value
UserForm1.ListBox1.List(UserForm1.ListBox1.ListCou nt - 1,
2) = Cell.Offset(0, 2)
UserForm1.ListBox1.List(UserForm1.ListBox1.ListCou nt - 1,
3) = Cell.Offset(0, 3)
UserForm1.ListBox1.List(UserForm1.ListBox1.ListCou nt - 1,
4) = Cell.Offset(0, 4)
UserForm1.ListBox1.List(UserForm1.ListBox1.ListCou nt - 1,
5) = Cell.Offset(0, 5)
UserForm1.ListBox1.List(UserForm1.ListBox1.ListCou nt - 1,
6) = Cell.Offset(0, 6)
UserForm1.ListBox1.List(UserForm1.ListBox1.ListCou nt - 1,
7) = Cell.Offset(0, 7)
UserForm1.ListBox1.List(UserForm1.ListBox1.ListCou nt - 1,
8) = Cell.Offset(0, 8)
UserForm1.ListBox1.List(UserForm1.ListBox1.ListCou nt - 1,
9) = Format(Cell.Offset(0, 9), "hh:mm")
UserForm1.ListBox1.ColumnHeads = True
UserForm1.ListBox1.TextColumn = 9
End If
Next
end sub


--

Dave Peterson


hi,
Thanks but this workbook is gonna share by 100 other user from time to
time so i cannot simply set the time frame and add the items. Cause
some of the users enters the values earlier and some not. There is
only one control computer which need to see those entries according
to time frame so that I need to remove by using combobox1 and combo2
which will give me to choose time frame.
Thanks again for your reply


--

Dave Peterson