|
发表于 2014-5-27 16:39
|
显示全部楼层
本楼为最佳答案
- Private Sub CommandButton1_Click()
- Dim i As Range
- With Sheets("分类汇总")
- Select Case True
- Case Len(Me.TextBox1.Text) > 0
- Set i = Range("A2:A65536").Find(TextBox1, lookat:=xlWhole) '需要单元格匹配查找
- If Not i Is Nothing Then
- TextBox2 = i.Offset(, 2) '产品名称
- TextBox8 = i.Offset(, 1) 'YOLIFT展厅
- TextBox7 = i.Offset(, 3) '数量
- Else
- TextBox1 = ""
- TextBox2 = ""
- TextBox7 = ""
- TextBox8 = ""
- MsgBox "对不起!您查询的产品不存在,请核对编码输入是否有误。", 1 + 64, "错误提示!"
- End If
- Case Len(Me.TextBox8.Text) > 0
- Set i = Range("B2:B65536").Find(TextBox8, lookat:=xlWhole) '需要单元格匹配查找
- If Not i Is Nothing Then
- TextBox1 = i.Offset(, -1) '产品名称
- TextBox2 = i.Offset(, 1) 'YOLIFT展厅
- TextBox7 = i.Offset(, 2) '数量
- Else
- TextBox1 = ""
- TextBox2 = ""
- TextBox7 = ""
- TextBox8 = ""
- MsgBox "对不起!您查询的产品不存在,请核对编码输入是否有误。", 1 + 64, "错误提示!"
- End If
- Case Else
- MsgBox "对不起!请输入编码1或编号2 输入是否有误。", 1 + 64, "错误提示!"
- End Select
- End With
- End Sub
复制代码 |
|