|
- Public Sub VX_wang_way()
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Dim wb As Workbook, sht As Worksheet
- Dim oWb As Workbook, oSht As Worksheet
- Dim d As Object
- Dim ar(1 To 10000, 1 To 18)
- Set d = CreateObject("Scripting.Dictionary")
- Dim fp, fps
- Set wb = Application.ThisWorkbook
- Set sht = wb.Worksheets(1)
- fd = wb.Path & ""
- Set fs = CreateObject("Scripting.FileSystemObject").GetFolder(fd).Files
- For Each f In fs
- fn = f.Name
- fp = f.Path
- If fp Like "*保教退费.xlsx" Then
- Debug.Print fp
- Set oWb = Workbooks.Open(fp)
- '从文件名分割月份数字
- mon = Split(oWb.Name, "月")(0)
- '月份列
- c = mon + 3
- For Each oSht In oWb.Worksheets
- With oSht
- erow = .Cells(.Rows.Count, 1).End(xlUp).Row
- For i = 4 To erow
- Key = .Cells(i, 2).Value
- If Val(Key) <> 0 And Val(.Cells(i, 3).Value) <> 0 Then
- If d.exists(Key) = False Then
- r = d.Count + 1
- d(Key) = r
- ar(r, 1) = r '序号
- ar(r, 2) = .Name '班级
- ar(r, 3) = Key '姓名
- ar(r, c) = .Cells(i, 3).Value
- ar(r, 16) = ar(r, 16) + .Cells(i, 3).Value
- Else
- r = d(Key)
- ar(r, c) = .Cells(i, 4).Value
- ar(r, 16) = ar(r, 16) + .Cells(i, 3).Value
- End If
- End If
- Next i
- End With
- 'Stop
- Next oSht
- oWb.Close False
- End If
- Next
- With sht
- .UsedRange.Offset(3).Clear
- .Range("a4").Resize(10000, 18).Value = ar
- End With
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|