|
- Public arr As Variant, lr As Integer, 学校数 As Integer
- Public Sub 一键生成()
- Application.ScreenUpdating = False
- Sheet3.Cells.ClearContents
- lr = Sheet1.Range("a65536").End(xlUp).Row
- Call 排序处理
- Call 学校名称处理
- Sheet3.[a1:f1] = Array("学校", "定向分配人数", "一线", "定向", "定向外", "合计上线")
- For i = 1 To Sheet2.[f2].Value
- Set Rng = Sheet3.Range("a2:a" & 学校数).Find(arr(i, 2)).Offset(0, 2)
- If Not Rng Is Nothing Then Rng.Value = Rng.Value + 1
- Next
- Call 定向统计
- Application.ScreenUpdating = True
- End Sub
- Public Sub 排序处理()
- Application.ScreenUpdating = False
- Sheet1.Select
- yrr = Sheet1.Range("a1:c" & lr)
- Sheet1.Range("a2:c" & lr).Sort Key1:=Cells(2, 3).Resize(lr - 1), Order1:=xlDescending
- arr = Sheet1.Range("a2:c" & lr)
- Sheet1.[a1].Resize(lr, 3) = yrr
- Sheet3.Select
- Application.ScreenUpdating = True
- End Sub
- Public Sub 学校名称处理()
- Application.ScreenUpdating = False
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- For i = 1 To lr - 1
- d(arr(i, 2)) = ""
- Next
- Sheet3.[a2].Resize(d.Count, 1) = Application.Transpose(d.Keys)
- For i = 2 To Sheet2.[a1000].End(xlUp).Row
- For j = 2 To d.Count + 1
- If Sheet2.Cells(i, 1).Value = Sheet3.Cells(j, 1).Value Then Sheet3.Cells(j, 1).Offset(0, 1) = Sheet2.Cells(i, 1).Offset(0, 1)
- Next
- Next
- 学校数 = d.Count
- Application.ScreenUpdating = True
- End Sub
- Public Sub 定向统计()
- lw = arr(Sheet2.[f2].Value, 3)
- For i = Sheet2.[f2].Value + 1 To Sheet2.[f1].Value
- Set Rng = Sheet3.Range("a2:a" & 学校数).Find(arr(i, 2)).Offset(0, 3)
- If Not Rng Is Nothing Then
- If arr(i, 3) + 40 >= lw And Rng.Value < Rng.Offset(0, -2) Then
- Rng.Value = Rng.Value + 1
- Else
- Rng.Offset(0, 1) = Rng.Offset(0, 1) + 1
- End If
- End If
- Next
- Range("F2:F" & 学校数 + 1).FormulaR1C1 = "=SUM(RC[-3]:RC[-1])"
- End Sub
复制代码
|
|