|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
表结构改了一下,仅供参考。。。
不再跟进。
- Sub ykcbf() '//2024.5.6
- Dim arr, brr, d, s
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("scripting.dictionary")
- Set sh = ThisWorkbook.Sheets("班级任课教师及任课节数汇总表")
- m = 1: n = 1
- On Error Resume Next
- With Sheets("总功课表(教师名字版)")
- r = .Cells(Rows.Count, 1).End(3).Row
- col = .UsedRange.Columns.Count
- arr = .[a1].Resize(r, col)
- ReDim brr(1 To UBound(arr), 1 To 300)
- For i = 2 To UBound(arr)
- If arr(i, 1) <> Empty Then
- s = arr(i, 1)
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = s
- End If
- r = d(arr(i, 1))
- For j = 2 To UBound(arr, 2)
- If arr(i, j) <> Empty Then
- s = Trim(arr(i, j))
- If Not d.exists(s) Then
- n = n + 1
- d(s) = n
- brr(1, n) = s
- End If
- c = d(Trim(arr(i, j)))
- brr(r, c) = brr(r, c) + 1
- End If
- Next
- End If
- Next
- End With
- With sh
- .UsedRange.Clear
- .[a1].Resize(m, n) = brr
- .[a1].Resize(1, n).Interior.Color = 49407
- .[a2].Resize(m - 1, 1).Interior.Color = 5296274
- ActiveWindow.DisplayZeros = False
- Set Rng = .[a1].Resize(m, n)
- With Rng
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- With .Font
- .Name = "微软雅黑"
- .Size = 11
- End With
- End With
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- End Sub
复制代码
|
|