|
9#
楼主 |
发表于 2017-6-13 17:07:19
|
只看该作者
无人理,唉
只好一个人折腾了半天,用本方法做的,哪位高手能修改下?
Private Sub CommandButton6_Click()
Dim i, j As Integer
If Trim(TextBox1.Text) = "" Then
Exit Sub
ElseIf ComboBox1.Text = "" Then
MsgBox "请选择类别!", 0, "提示"
Exit Sub
End If
ListView1.ListItems.Clear '清除listview1中的内容
For i = 2 To Sheets(ComboBox1.Text).[A1048576].End(xlUp).Row
For j = 1 To 10
If Sheets(ComboBox1.Text).Cells(i, j) Like "*" & TextBox1.Text & "*" Then
Set ITM = ListView1.ListItems.Add() '为listview1控件里面的行添加内容
ITM.Text = Sheets(ComboBox1.Text).Cells(i, 1) '为行标赋值
ITM.SubItems(1) = Sheets(ComboBox1.Text).Cells(i, 2)
ITM.SubItems(2) = Sheets(ComboBox1.Text).Cells(i, 3)
ITM.SubItems(3) = Sheets(ComboBox1.Text).Cells(i, 4)
ITM.SubItems(4) = Sheets(ComboBox1.Text).Cells(i, 5)
ITM.SubItems(5) = Sheets(ComboBox1.Text).Cells(i, 6)
ITM.SubItems(6) = Sheets(ComboBox1.Text).Cells(i, 7)
ITM.SubItems(7) = Sheets(ComboBox1.Text).Cells(i, 8)
ITM.SubItems(8) = Sheets(ComboBox1.Text).Cells(i, 9)
ITM.SubItems(9) = Sheets(ComboBox1.Text).Cells(i, 10)
End If
Next j
Next i
End Sub
以上代码到时可以检索到并显示出来,问题是有些时候会出现很多重复的数据行,而且也无法进行删除修改操作。
哪位高手好心帮忙改改吧
|
|