|
- Sub tst()
- Dim i&, ph$, st$
- Dim wr As Workbook
- ph = ThisWorkbook.Path & ""
- st = Dir(ph & "*.xls*")
- With Sheet1
- .Range("a4").Resize(.UsedRange.Rows.Count, 1).EntireRow.Delete
- End With
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Do While st <> ""
- If st <> ThisWorkbook.Name Then
- Set wr = Workbooks.Open(ph & st)
- With wr.Sheets(1)
- .AutoFilterMode = False
- i = .Cells(.Cells.Rows.Count, 2).End(3).Row
- If i > 3 And .Cells(2, 2) = "上报时间" Then
- .Cells(4, 1).Resize(i - 3, 1).EntireRow.Copy
- With ThisWorkbook.Sheets(1)
- i = .Cells(.Cells.Rows.Count, 2).End(3).Row
- If i < 4 Then i = 4 Else i = i + 1
- .Cells(i, 1).PasteSpecial
- End With
- End If
- End With
- Application.CutCopyMode = False
- wr.Close (False)
- Set wr = Nothing
- End If
- st = Dir()
- Loop
-
-
- With Sheet1
- i = .Cells(.Cells.Rows.Count, 2).End(3).Row
- If i > 4 Then
- .Cells(4, 1).Resize(i - 3, 20).Sort .Cells(1, 2), xlAscending, , , , , , xlNo
- ReDim brr(1 To i - 3, 1 To 1)
- For i = 1 To UBound(brr)
- brr(i, 1) = i
- Next i
- .Cells(4, 1).Resize(UBound(brr), 1) = brr
- End If
- End With
- Call hz
- Application.ScreenUpdating = True
- Application.DisplayAlerts = True
- MsgBox "完成"
- End Sub
复制代码
|
|