|
Private Sub Query_Click()
Worksheets("在职人员").Select
Dim i As Integer
i = 0
Dim Num As Long
Dim str As String
Num = Worksheets("在职人员").Range("D1048576").End(xlUp).Row
str = InputBox("请输入需要查询的姓名")
Range("AS2").FormulaR1C1 = "=countif(DataArea,""" & str & """)"
Dim MyArray(6, 10) As String
MyArray(0, 0) = "序号"
MyArray(1, 0) = "员工编号"
MyArray(2, 0) = "姓名"
MyArray(3, 0) = "性别"
MyArray(4, 0) = "现职位"
MyArray(5, 0) = "现部门"
If Range("AS2").Value > 1 Then (这是出现错误的地方)
员工信息管理.Height = 447
w_UserList.Visible = True
With Worksheets(1).Range("DataArea")
Set c = .Find(str, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
i = i + 1
MyArray(0, i) = Cells(c.Row, 1)
MyArray(1, i) = Cells(c.Row, 3)
MyArray(2, i) = Cells(c.Row, 4)
MyArray(3, i) = Cells(c.Row, 6)
MyArray(4, i) = Cells(c.Row, 33)
MyArray(5, i) = Cells(c.Row, 32)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
w_UserList.Column() = MyArray
Exit Sub
End If
With Worksheets(1).Range("DataArea")
Set c = .Find(str, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
w_b_WorkerID.Text = Cells(c.Row, 3)
w_b_WorkerName.Text = Cells(c.Row, 4)
w_b_BirthDay.Text = Cells(c.Row, 5)
w_b_Sex.Text = Cells(c.Row, 6)
w_b_Marry.Text = Cells(c.Row, 7)
w_b_Stu.Text = Cells(c.Row, 8)
w_b_Chen.Text = Cells(c.Row, 9)
w_b_StuTech.Text = Cells(c.Row, 10)
w_b_School.Text = Cells(c.Row, 11)
w_b_Mobel.Text = Cells(c.Row, 12)
w_b_Number.Text = Cells(c.Row, 13)
w_b_Address.Text = Cells(c.Row, 14)
w_b_NowAddress.Text = Cells(c.Row, 15)
w_b_HomeTelphone.Text = Cells(c.Row, 16)
w_b_WorkTime.Text = Cells(c.Row, 17)
w_b_FName.Text = Cells(c.Row, 18)
w_b_FWork.Text = Cells(c.Row, 19)
w_b_Type.Text = Cells(c.Row, 20)
w_b_HouseCarID.Text = Cells(c.Row, 21)
w_b_CarID.Text = Cells(c.Row, 22)
w_b_TechBook.Text = Cells(c.Row, 23)
w_b_TechTime.Text = Cells(c.Row, 24)
w_w_Time.Text = Cells(c.Row, 25)
w_w_WorkTime.Text = Cells(c.Row, 26)
w_w_WorkStu.Text = Cells(c.Row, 27)
w_w_WorkingTime.Text = Cells(c.Row, 28)
w_w_Dep.Text = Cells(c.Row, 32)
w_w_Worker.Text = Cells(c.Row, 33)
w_w_DepS.Text = Cells(c.Row, 34)
w_w_WorkID.Text = Cells(c.Row, 35)
w_b_Image.Picture = LoadPicture("C:\Users\Administrator\Desktop\素材图片\" & Cells(c.Row, 2))
cs = c.Row
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
End Sub
|
|