B
baha17
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.ListCount - 1,
2) = Cell.Offset(0, 2)
UserForm1.ListBox1.List(UserForm1.ListBox1.ListCount - 1,
3) = Cell.Offset(0, 3)
UserForm1.ListBox1.List(UserForm1.ListBox1.ListCount - 1,
4) = Cell.Offset(0, 4)
UserForm1.ListBox1.List(UserForm1.ListBox1.ListCount - 1,
5) = Cell.Offset(0, 5)
UserForm1.ListBox1.List(UserForm1.ListBox1.ListCount - 1,
6) = Cell.Offset(0, 6)
UserForm1.ListBox1.List(UserForm1.ListBox1.ListCount - 1,
7) = Cell.Offset(0, 7)
UserForm1.ListBox1.List(UserForm1.ListBox1.ListCount - 1,
8) = Cell.Offset(0, 8)
UserForm1.ListBox1.List(UserForm1.ListBox1.ListCount - 1,
9) = Format(Cell.Offset(0, 9), "hh:mm")
UserForm1.ListBox1.ColumnHeads = True
UserForm1.ListBox1.TextColumn = 9
End If
Next
end sub
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.ListCount - 1,
2) = Cell.Offset(0, 2)
UserForm1.ListBox1.List(UserForm1.ListBox1.ListCount - 1,
3) = Cell.Offset(0, 3)
UserForm1.ListBox1.List(UserForm1.ListBox1.ListCount - 1,
4) = Cell.Offset(0, 4)
UserForm1.ListBox1.List(UserForm1.ListBox1.ListCount - 1,
5) = Cell.Offset(0, 5)
UserForm1.ListBox1.List(UserForm1.ListBox1.ListCount - 1,
6) = Cell.Offset(0, 6)
UserForm1.ListBox1.List(UserForm1.ListBox1.ListCount - 1,
7) = Cell.Offset(0, 7)
UserForm1.ListBox1.List(UserForm1.ListBox1.ListCount - 1,
8) = Cell.Offset(0, 8)
UserForm1.ListBox1.List(UserForm1.ListBox1.ListCount - 1,
9) = Format(Cell.Offset(0, 9), "hh:mm")
UserForm1.ListBox1.ColumnHeads = True
UserForm1.ListBox1.TextColumn = 9
End If
Next
end sub