|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Option Explicit
Sub TEST6()
Dim ar, br, i&, j&, k&, r&, dic As Object, iPosCol&, iPosRow&, strKey$
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
With Worksheets(1)
With [A1].CurrentRegion
.Offset(3).Clear
ar = .Resize(10 ^ 3).Value
r = 2
End With
For j = 2 To UBound(ar, 2)
If Len(ar(2, j)) Then dic(ar(2, j)) = j
Next j
For k = 2 To Worksheets.Count
With Worksheets(k)
With Range(.[A1], .UsedRange)
br = Intersect(.Offset(), .Offset(1))
For j = 3 To UBound(br, 2)
If dic.exists(br(1, j)) Then
iPosCol = dic(br(1, j))
For i = 2 To UBound(br)
If br(i, 1) Like "C*" Then
strKey = br(i, 1) & "," & br(i, 2)
If Not dic.exists(strKey) Then
r = r + 1
dic(strKey) = r
End If
iPosRow = dic(strKey)
ar(iPosRow, 1) = br(i, 1): ar(iPosRow, 2) = br(i, 2)
ar(iPosRow, iPosCol) = br(i, j)
End If
Next i
End If
Next j
End With
End With
Next k
With .[A1].Resize(r, UBound(ar, 2))
.Value = ar
.Borders.LineStyle = xlContinuous
End With
End With
Set dic = Nothing
Application.ScreenUpdating = True
Beep
End Sub
|
评分
-
1
查看全部评分
-
|