【发布时间】:2018-08-23 11:01:45
【问题描述】:
我的用户窗体上有 1 个组合框和 2 个列表框:
cbox_rrhhlbox_porlbox_done
还有一张这样的“Pedidos”表:
我找到了一种方法来过滤组合框值之后的列表框数据,该值是“J”列 ex(roraima,karla,yvonne,sara) 中的值,但我还需要在 lbox_por 上显示行如果是“否”,则列“J”与“Si”匹配,必须在 lbox_done 中加载这些行。
使用的代码:
Private Sub cbo_rrhh_Change()
Dim Cell As Range 'defining your searcharea
Dim Row_Counter As Integer 'rowno
Dim Pos As Integer 'rowno in array
Dim MyList() As String 'the array
Dim No_Pos As Integer 'total rows in aray
Dim Search_name As String 'searchvalue in combobox
Dim Real_last_row As Integer 'last row in "Pedidos"
'xllastrow is a function
Real_last_row = xlLastRow("Pedidos") 'last row in "Pedidos"
Search_name = cbo_rrhh.Value
'Searching in "Pedidos" for matches with searchstring
For Each Cell In Worksheets("Pedidos").Range("J2:J" & Real_last_row)
If Cell Like "*" & Search_name & "*" Then
'If a value matches with the searchstring, number of rows of array is + 1
No_Pos = No_Pos + 1
End If
Next Cell
Row_Counter = 2 'start of the nameslist
Pos = 0 'rowno in array, beginning with zero
ReDim Preserve MyList(No_Pos, 8) 'Redimming of array with total no of rows and 3 columns
'if value isn't in searchstring then rowno is rowno + 1
'if a match is found the array is filled and the rowno in array is + 1
For Each Cell In Worksheets("Pedidos").Range("J2:J" & Real_last_row)
If Cell Like "*" & Search_name & "*" Then
MyList(Pos, 0) = Worksheets("Pedidos").Range("A" & Row_Counter)
MyList(Pos, 1) = Worksheets("Pedidos").Range("B" & Row_Counter)
MyList(Pos, 2) = Worksheets("Pedidos").Range("C" & Row_Counter)
MyList(Pos, 3) = Worksheets("Pedidos").Range("E" & Row_Counter)
MyList(Pos, 4) = Worksheets("Pedidos").Range("F" & Row_Counter)
MyList(Pos, 5) = Worksheets("Pedidos").Range("G" & Row_Counter)
MyList(Pos, 6) = Worksheets("Pedidos").Range("H" & Row_Counter)
MyList(Pos, 7) = Worksheets("Pedidos").Range("I" & Row_Counter)
MyList(Pos, 8) = Worksheets("Pedidos").Range("J" & Row_Counter)
Pos = Pos + 1
Row_Counter = Row_Counter + 1
Else
Row_Counter = Row_Counter + 1
End If
Next Cell
Application.ShowToolTips = True
With lbox_por
.ColumnCount = 10 'no of columns (0,1,2)
.ControlTipText = "Pedidos pendientes ..." 'tiptext
End With
With lbox_done
.ColumnCount = 9 'no of columns (0,1,2)
.ControlTipText = "Pedidos realizados ..." 'tiptext
End With
lbox_por.List = MyList 'define the list of listbox1
lbox_done.List = MyList
End Sub
对于上下文: Fecha:意思是日期。 帕拉布拉斯:词。 塔萨:率。 蒙托:数量。 帕加多:付清了。 编辑:作家。
【问题讨论】: