|
Option Explicit
Sub TEST()
Dim ar, br, i&, j&, r&, n&, dic As Object, iPosCol&, wks As Worksheet
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
If Trim([N1]) = "" Then MsgBox "日期为空,请检查!": Exit Sub
With [A1].CurrentRegion
.Offset(1).Clear
ar = .Resize(10 ^ 4)
For i = 1 To UBound(ar, 2): dic(ar(1, i)) = i: Next
r = 1
End With
For Each wks In Sheets
If wks.Name <> "汇总" Then
br = wks.[A1].CurrentRegion
n = 0
For i = 1 To UBound(br, 2)
If br(1, i) = "日期" Then: n = i: Exit For
Next i
If n <> 0 Then
For i = 2 To UBound(br)
If br(i, n) = [N1] Then
r = r + 1
For j = 1 To UBound(br, 2)
If dic.exists(br(1, j)) Then
iPosCol = dic(br(1, j))
ar(r, iPosCol) = br(i, j)
End If
Next j
End If
Next i
End If
End If
Next
With [A1].Resize(r, UBound(ar, 2))
.Columns(2).NumberFormatLocal = "yyyy-m-m"
.Value = ar
End With
Set dic = Nothing
Application.ScreenUpdating = True
Beep
End Sub
|
评分
-
1
查看全部评分
-
|