|
Private Sub ComboBox1_Change()
Dim arr, ar(1 To 100)
Dim x, y As Integer
arr = Range("c5:e" & Range("d" & Rows.Count).End(xlUp).Row)
For x = 1 To UBound(arr)
If arr(x, 1) = ComboBox1.Value Then
y = y + 1
ar(y) = arr(x, 2)
Do
x = x + 1
If arr(x, 1) = "" Then
y = y + 1
ar(y) = arr(x, 2)
End If
Loop Until arr(x, 1) <> "" Or x = UBound(arr)
Exit For
End If
Next x
ListBox1.List = ar
End Sub
Private Sub ComboBox1_Enter()
ComboBox1.DropDown
End Sub
Private Sub CommandButton1_Click()
Dim a As Integer
Dim str, st As String
a = Range("d" & Rows.Count).End(xlUp).Row
If ComboBox1.Value = "" Then MsgBox "请选择部门!": ComboBox1.SetFocus: Exit Sub
If ListBox1.ListIndex = -1 Then MsgBox "请选择员工": ListBox1.SetFocus: Exit Sub
If TextBox1.Value = "" Then MsgBox "请输入密码!": TextBox1.SetFocus: Exit Sub
str = ListBox1.List(ListBox1.ListIndex, 0)
st = Range("d5:d" & a).Find(str).Offset(, 1)
If TextBox1.Value = st Then
MsgBox "成功登录!"
Unload Me
Else
MsgBox "密码错误,请重新输入!"
TextBox1.SetFocus
End If
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim arr1, arr2
Dim m, n, i, q As Integer
m = Range("c" & Rows.Count).End(xlUp).Row
n = Application.CountA(Range("c5:c" & m))
ReDim arr1(1 To n)
Do
If Cells(5 + q, 3).Value <> "" Then
i = i + 1
arr1(i) = Cells(5 + q, 3)
End If
q = q + 1
Loop Until i = n
ComboBox1.List = arr1
End Sub
|
评分
-
查看全部评分
|