|
Sub 静态计划查询() '非数组
Dim arr() As Variant, Item As Integer, rng As Range, j As String
Dim Tim As Long
Application.ScreenUpdating = False
Range("A2:D" & Cells(Rows.Count, 1).End(xlUp).Row).Clear
j = Application.InputBox("请输入查询的年和月,如,2011-01", "查询设置", , , , , 2)
'遍历所有成绩
For Each rng In Sheet1.Range("H3:H" & Sheet1.Cells(Rows.Count, 1).End(xlUp).Row)
'如果符合要求
If Left(rng, 7) = j Then
Item = Item + 1 '累加变量
'将查找到到了成绩和姓名罗列在A\B列
Cells(Item + 2, "A") = rng.Offset(0, -7).Text
Cells(Item + 2, "B") = rng.Offset(0, -6).Text
Cells(Item + 2, "C") = rng.Offset(0, -2).Text
Cells(Item + 2, "D") = rng.Text
End If
Next rng
[A2:D2] = Array("Frequency", "AHU", "Mission", "Due Date")
With Range("A3:D" & Cells(Rows.Count, 1).End(xlUp).Row)
.Font.Size = 8
.Font.Name = "Tahoma"
.Borders.LineStyle = xlContinuous
.ShrinkToFit = True
End With
With Range("A2:D2")
.Font.Size = 10
.Font.Name = "Tahoma"
.Font.Bold = True
.Borders.LineStyle = xlContinuous
.ShrinkToFit = True
End With
Application.ScreenUpdating = True
End Sub
|
|