|
Private Sub CommandButton1_Click()
On Error Resume Next
If OptionButton1 = True Then lh = 2 '列号
If OptionButton2 = True Then lh = 6
If OptionButton3 = True Then lh = 7
If lh = "" Then MsgBox "请选择查询类型!": GoTo 100
r = Sheets("数据").Cells(Rows.Count, 1).End(xlUp).Row
If r < 2 Then MsgBox "数据工作表为空!": Exit Sub
arr = Sheets("数据").Range("a1:i" & r)
ReDim arr1(1 To UBound(arr), 1 To 9)
ReDim arr1(1 To UBound(arr), 1 To 9)
arr1(1, 1) = "日期"
arr1(1, 2) = "客户姓名"
arr1(1, 3) = "客户电话"
arr1(1, 4) = "商品名称"
arr1(1, 5) = "配置"
arr1(1, 6) = "车架号码"
arr1(1, 7) = "电机号码"
arr1(1, 8) = "业务员"
arr1(1, 9) = "附加说明"
t = UCase(TextBox1)
For i = 2 To UBound(arr)
If InStr(UCase(arr(i, lh)), UCase(TextBox1)) Then
n = n + 1
For x = 1 To 9
arr1(n + 1, x) = arr(i, x)
Next x
End If
Next i
With ListBox1
.ColumnCount = 9
.TextAlign = 2
.List = arr1
.ColumnWidths = "30;80;60;60;100;60;60;6;60"
End With
If n = "" Then
MsgBox "无该用户,请查正后输入!"
Else
Me.ListBox1.Visible = True
End If
100:
End Sub
|
|