|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub Main_HUizongChengji()
- '---select path
- With Application.FileDialog(msoFileDialogFolderPicker)
- .Title = "Choose the Folder where Files ar located"
- .InitialFileName = ThisWorkbook.Path & ""
- If .Show Then Mypth = .SelectedItems(1) Else Exit Sub
- End With
- On Error Resume Next
- AppSet False
- Dim wb As Workbook
- Dim arr(1 To 99999, 1 To 6) '---jieguo shuzu
- Set d = CreateObject("scripting.dictionary")
- Set fso = CreateObject("Scripting.FileSystemObject")
- For Each f In fso.GetFolder(Mypth).Files
- If Not f.Name Like "~*" Then
- Set wb = Workbooks.Open(f)
- ar = wb.Sheets(1).UsedRange.Value
- k = InStr("数学语文英语", Left(ar(1, 4), 2))
- If k > 0 Then
- k = (k \ 2) + 4
- For i = 2 To UBound(ar)
- code = CStr(ar(i, 3))
- If Not d.exists(code) Then
- r = r + 1
- d(code) = r
- arr(r, 1) = r
- arr(r, 2) = ar(i, 2)
- arr(r, 3) = code
- End If
- j = d(code)
- arr(j, k) = Val(ar(i, 4))
- Next
- End If
- wb.Close False
- End If
- Next
- If r > 0 Then
- With Sheet1
- .UsedRange.Offset(1).ClearContents
- .Range("a2").Resize(r, 6).Value = arr
- End With
- End If
- AppSet True
- End Sub
- Public Sub AppSet(AppBl As Boolean)
- With Application
- .ScreenUpdating = AppBl
- .DisplayAlerts = AppBl
- .EnableEvents = AppBl
- .AskToUpdateLinks = AppBl
- If AppBl Then
- .Calculation = xlCalculationAutomatic
- Else
- .Calculation = xlCalculationManual
- End If
- End With
- End Sub
复制代码 |
|