|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Private Sub ComboBox1_Change()
On Error Resume Next
With Sheets("6月份带班分工表")
x = .Range("C:C").Find(ComboBox1.Text).Row
ComboBox9.Text = .Cells(x, 1)
ComboBox2.Text = .Cells(x, 4)
End With
Call p1
End Sub
Private Sub ComboBox2_Change()
On Error Resume Next
With Sheets("6月份带班分工表")
x = .Range("D:D").Find(ComboBox2.Text).Row
ComboBox9.Text = .Cells(x, 1)
ComboBox1.Text = .Cells(x, 3)
End With
Call p1
End Sub
Private Sub ComboBox3_Change()
On Error Resume Next
If ComboBox3.ListIndex <> -1 And ComboBox4.Text <> "" Then
ComboBox7.Clear
ComboBox4.SetFocus
Dim x As Byte
For x = 1 To Day(DateSerial(ComboBox3.Text, ComboBox4 + 1, 0))
ComboBox7.AddItem DateSerial(ComboBox3.Text, ComboBox4, x)
Next
ComboBox7.ListIndex = 0
End If
End Sub
Private Sub ComboBox4_Change()
On Error Resume Next
If ComboBox4.ListIndex <> -1 And ComboBox3.Text <> "" Then
ComboBox7.Clear
Dim x As Byte
For x = 1 To Day(DateSerial(ComboBox3.Text, ComboBox4 + 1, 0))
ComboBox7.AddItem DateSerial(ComboBox3.Text, ComboBox4, x)
Next
End If
ComboBox7.ListIndex = 0
End Sub
Private Sub ComboBox5_Change()
On Error Resume Next
If ComboBox5.ListIndex <> -1 And ComboBox6.Text <> "" Then
ComboBox8.Clear
ComboBox6.SetFocus
Dim x As Byte
For x = 1 To Day(DateSerial(ComboBox5.Text, ComboBox6 + 1, 0))
ComboBox8.AddItem DateSerial(ComboBox5.Text, ComboBox6, x)
Next
ComboBox8.ListIndex = 0
End If
End Sub
Private Sub ComboBox6_Change()
On Error Resume Next
If ComboBox6.ListIndex <> -1 And ComboBox5.Text <> "" Then
ComboBox8.Clear
Dim x As Byte
For x = 1 To Day(DateSerial(ComboBox5.Text, ComboBox6 + 1, 0))
ComboBox8.AddItem DateSerial(ComboBox5.Text, ComboBox6, x)
Next
End If
ComboBox8.ListIndex = 0
End Sub
Private Sub ComboBox9_Change()
On Error Resume Next
With Sheets("6月份带班分工表")
x = .Range("A:A").Find(ComboBox9.Text).Row
ComboBox1.Text = .Cells(x, 3)
ComboBox2.Text = .Cells(x, 4)
End With
Call p1
End Sub
Private Sub CommandButton1_Click()
'If CheckBox1.Value = False And CheckBox2.Value = False And CheckBox3.Value = False Then
'MsgBox "请选择填充的时间段!!", 16, "提示"
'Exit Sub
'End If
'Cells.Interior.Pattern = xlNone
If ComboBox1.Text = "" Then
ComboBox1.SetFocus
MsgBox "班级为空!!", 64, "请选择下拉列表"
Else
If MsgBox("是否“" & Me.ActiveControl.Caption & "” ?", 36, "询问") = 7 Then Exit Sub
With Selection
.Interior.ColorIndex = 4
.Value = ComboBox1.Text
End With
With Sheets("6月份带班分工表")
.Cells(.Range("C:C").Find(ComboBox1.Text).Row, 4) = Cells(ActiveCell.Row, 1) & "-" & Cells(ActiveCell.Row, 2)
End With
Unload Me
End If
End Sub
Private Sub CommandButton2_Click()
'If MsgBox("是否退出", 36, "询问") = 7 Then Exit Sub
Unload Me
End Sub
Private Sub p1()
On Error Resume Next
With Sheets("6月份带班分工表")
x = .Cells(.Range("A:A").Find(ComboBox9.Text).Row, 2)
a = Left(x, InStr(x, "—") - 1)
a1 = Val(Left(a, InStr(a, "月") - 1))
a2 = Val(Replace(Right(a, Len(a) - InStr(a, "月")), "日", ""))
b = Right(x, Len(x) - InStr(x, "—"))
b1 = Val(Left(b, InStr(b, "月") - 1))
b2 = Val(Replace(Right(b, Len(b) - InStr(b, "月")), "日", ""))
ComboBox3.Text = Left(.Cells(.Range("A:A").Find(ComboBox9.Text).Row, 1), 4)
ComboBox4.Text = a1
ComboBox7.Text = Format(DateSerial(Left(.Cells(.Range("A:A").Find(ComboBox9.Text).Row, 1), 4), a1, a2), "yyyy-m-dd")
ComboBox5.Text = Left(.Cells(.Range("A:A").Find(ComboBox9.Text).Row, 1), 4)
ComboBox6.Text = b1
ComboBox8.Text = Format(DateSerial(Left(.Cells(.Range("A:A").Find(ComboBox9.Text).Row, 1), 4), b1, b2), "yyyy-m-dd")
End With
End Sub
Private Sub UserForm_Activate()
With Sheets("教室安排情况")
For a = .Range("B" & Rows.Count).End(xlUp).Row To 4 Step -1
For b = 0 To ComboBox2.ListCount - 1
If .Cells(a, 2) = ComboBox2.List(b) Then GoTo 100
Next b
ComboBox2.AddItem .Cells(a, 2)
100:
Next a
End With
Dim x As Integer
For x = 1 To 12
ComboBox4.AddItem x
ComboBox6.AddItem x
Next
Dim y As Integer
For y = 0 To 10
ComboBox3.AddItem 2010 + y
ComboBox5.AddItem 2010 + y
Next
With Sheets("6月份带班分工表")
Dim z As Integer
For z = 3 To .Range("A" & Rows.Count).End(xlUp).Row Step 1
ComboBox9.AddItem .Cells(z, 1)
ComboBox1.AddItem .Cells(z, 3)
Next
End With
End Sub
Private Sub UserForm_Initialize()
ComboBox3.Text = Year(Date)
ComboBox5.Text = Year(Date)
ComboBox4.Text = Month(Date)
ComboBox6.Text = Month(Date)
ComboBox7.Text = VBA.DateSerial(ComboBox3.Text, ComboBox4.Text, 1)
ComboBox8.Text = VBA.DateSerial(ComboBox3.Text, ComboBox4.Text + 1, 0)
End Sub
[ 本帖最后由 daley 于 2010-6-27 05:51 编辑 ] |
|