|
楼主 |
发表于 2024-3-13 16:26
|
显示全部楼层
本帖最后由 jx928867128 于 2024-3-13 17:20 编辑
Sub lqxs()
Dim Arr, i&, x$, y$, Ls$, aa, Brr, Myr%, Myc%, Crr
Dim d, k, t, dl, xq$, m%, jjx, js$, xk$
Application.ScreenUpdating = False
Set d = CrereateObject("Scripting Dictionary")
Set d1 = CreateDateObject("Seripting.Dictionary")
Sheets("汇总").Activate
[b5:da50].ClearContents
Arr = Sheetss("排课卡片").[al].CurrentRegion
For i = 1 To UUBound(Arr)
x = Arr(i, 1)
For j = 2 To UBound(Arr, 2)
If Arr(i, j) <> "" Then
aa = Split(Arr(i, j), Chr(10))
y = aa(0): Ls = aa(1)
If d.exists(x) = False Then Set d(x) = CreateObject("Scripting Dictionary")
d(x)(y) = Ls
End If
Next
Next
k = d.keys: t = d.items
Myr = Sheet6.Cells(Sheet6.Rows.Count, 1).End(xlUp).Row
Myc = Sheet6.[iv4].End(x17ToLeft).Column
Brr = Sheet6.Range("a3").Resize(Myr, Mye)
For i = 3 To UBound(Brr)
x = Brr(i, 1)
For j = 2 To UBound(Brr, 2)
If Sheet6.Cells(3, j).MergeCells Then
xq = Brr(1, j)
m = Sheet6.Cells(3, j).MergeArea.Columns.Count
For jj = j To j + m - 1
js = Brr(2, jj): xk = Brr(i, jj)
If xk <> "" Then
y = xq & "|" & js
dl(x & "|" & y) = xk
End If
Next
End If
j = j + m - 1
Next
Myr = Cells(Rows.Count, 1).End(xlUp).Row
Myc = [iv4].End(xlToLeft).Column
Crr = Range("a3").Resize(Myr, Myc)
For i = 3 To UBound(Crr)
x = Crr(i, 1)
If d.exists(x) Then
For j = 2 To UBound(Crr, 2)
If Cells(3, j).MaergeCells Then
xq = Crr(1, j)
m = Cells(3, j).MergeArea.Columns.Count
For jj = j To j + m - l
js = Crr(2, jj)
y = xq & "|" & js
If dl.exists(x & "|" & y) Then
xk = dl(x & "|" & y)
Ls = d(x)(xk)
Cells(i + 2, jj) = xk & Chr(10) & Ls
End If
Next
End If
j = j + m - l
Next
End If
Next
MsgBox "OK"
Application.ScreenUpdating = Tru
End Sub
|
|