Private Sub CommandButton1_Click() ''录入
yg = ComboBox1.Text
xm = ComboBox2.Text
rq = ComboBox3.Text
sl = TextBox1.Text
rr = Array(yg, xm, rq, sl)
For i = 0 To UBound(rr)
If rr(i) = "" Then
m = m + 1
End If
Next i
If m <> "" Then MsgBox "请把信息录入完整!": Exit Sub
Dim rn As Range
With Sheets(yg)
r = .Cells(Rows.Count, 2).End(xlUp).Row
Set rn = .Range("b3:c" & r).Find(xm, , , , , , 1)
If rn Is Nothing Then MsgBox yg & "中找不到" & xm & "!": Exit Sub
w = rn.Row
lh = Val(rq) + 3
.Cells(w, lh) = sl
End With
ComboBox2.Text = ""
MsgBox "录入成功!"
End Sub
Private Sub CommandButton2_Click()
Unload UserForm1
End Sub
Private Sub UserForm_Initialize()
Dim d As Object
Set d = CreateObject("scripting.dictionary")
For Each sh In Sheets
If sh.Index > 1 Then
d(sh.Name) = ""
End If
Next sh
ComboBox1.List = d.keys
With Sheet2
r = .Cells(Rows.Count, 2).End(xlUp).Row
ar = .Range("b3:b" & r)
End With
ComboBox2.List = ar
ComboBox3.List = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31)
End Sub
|