Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
ListBox Add Item based on criteria
I have a list box that is populated by the code below. I am having trouble
just showing todays entries. Column G is a time stamp of the entries made and I would like the listbox to just show today's and not all the entries in the excel database. If Workbooks(xlDatabaseName).Sheets(xlTable).Range("A 2") < "" Then With Workbooks(xlDatabaseName).Sheets(xlTable) Set Rng = .Range("A1", .Range("A1").End(xlDown)) Set co = cell.Offset End With For Each cell In Rng.Cells With UserForm1.ListBox1 .AddItem cell.Value .List(.ListCount - 1, 1) = cell.Offset(0, 1).Value .List(.ListCount - 1, 2) = cell.Offset(0, 2).Value .List(.ListCount - 1, 3) = cell.Offset(0, 3).Value .List(.ListCount - 1, 4) = cell.Offset(0, 4).Value .List(.ListCount - 1, 5) = cell.Offset(0, 5).Value .List(.ListCount - 1, 6) = cell.Offset(0, 6).Value If .ListCount 5 Then .TopIndex = .ListCount - 5 End If If CheckBox1.Value = True Then .ListIndex = .ListCount - 1 End If End With Next cell End If Thanks in advance |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
ListBox Add Item based on criteria
If Workbooks(xlDatabaseName).Sheets(xlTable).Range("A 2") < "" Then
With Workbooks(xlDatabaseName).Sheets(xlTable) Set Rng = .Range("A1", .Range("A1").End(xlDown)) Set co = cell.Offset End With For Each cell In Rng.Cells With UserForm1.ListBox1 if clng(cell.offset(0,6).Value) = clng(date) then .AddItem cell.Value .List(.ListCount - 1, 1) = cell.Offset(0, 1).Value .List(.ListCount - 1, 2) = cell.Offset(0, 2).Value .List(.ListCount - 1, 3) = cell.Offset(0, 3).Value .List(.ListCount - 1, 4) = cell.Offset(0, 4).Value .List(.ListCount - 1, 5) = cell.Offset(0, 5).Value .List(.ListCount - 1, 6) = cell.Offset(0, 6).Value If .ListCount 5 Then .TopIndex = .ListCount - 5 End If If CheckBox1.Value = True Then .ListIndex = .ListCount - 1 End If End if End With Next cell End If -- Regards, Tom Ogilvy "James W." wrote in message ... I have a list box that is populated by the code below. I am having trouble just showing todays entries. Column G is a time stamp of the entries made and I would like the listbox to just show today's and not all the entries in the excel database. If Workbooks(xlDatabaseName).Sheets(xlTable).Range("A 2") < "" Then With Workbooks(xlDatabaseName).Sheets(xlTable) Set Rng = .Range("A1", .Range("A1").End(xlDown)) Set co = cell.Offset End With For Each cell In Rng.Cells With UserForm1.ListBox1 .AddItem cell.Value .List(.ListCount - 1, 1) = cell.Offset(0, 1).Value .List(.ListCount - 1, 2) = cell.Offset(0, 2).Value .List(.ListCount - 1, 3) = cell.Offset(0, 3).Value .List(.ListCount - 1, 4) = cell.Offset(0, 4).Value .List(.ListCount - 1, 5) = cell.Offset(0, 5).Value .List(.ListCount - 1, 6) = cell.Offset(0, 6).Value If .ListCount 5 Then .TopIndex = .ListCount - 5 End If If CheckBox1.Value = True Then .ListIndex = .ListCount - 1 End If End With Next cell End If Thanks in advance |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Last Item of Listbox not getting displayed | Excel Discussion (Misc queries) | |||
Adding item in listbox | Excel Worksheet Functions | |||
Adding item in listbox | Excel Worksheet Functions | |||
Item order in ListBox | Excel Discussion (Misc queries) | |||
The value of a ListBox Item | Excel Programming |