|
本帖最后由 ykcbf1100 于 2024-2-5 20:52 编辑
参与一下。。。- Sub ykcbf() '//2024.2.5
- Dim arr, brr(1 To 10000, 1 To 50)
- Set Fso = CreateObject("scripting.filesystemobject")
- Set List = CreateObject("System.Collections.ArrayList")
- Application.ScreenUpdating = False
- Set sh = ThisWorkbook.Sheets("个人所得税扣缴申报表")
- p = ThisWorkbook.Path & ""
- For Each f In Fso.GetFolder(p).Files
- If f.Name Like "*.xls*" Then
- If InStr(f.Name, ThisWorkbook.Name) = 0 Then
- fn = Fso.GetBaseName(f)
- ny = Split(fn, "_")(0)
- List.Add ny
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets(1)
- arr = .UsedRange
- wb.Close False
- End With
- For i = 9 To UBound(arr)
- If Val(arr(i, 1)) Then
- m = m + 1
- brr(m, 1) = m
- brr(m, 2) = Format(Val(Mid(fn, 6)), "00") & "月"
- brr(m, 3) = arr(i, 2)
- For j = 3 To UBound(arr, 2)
- brr(m, j + 1) = arr(i, j)
- Next
- End If
- Next
- End If
- End If
- Next f
- List.Sort
- rq1 = Format(CDate(List(0)), "yyyy年mm月dd日")
- rq2 = Replace(Format(CDate(List(List.Count - 1)), "yyyy年mm月dd日"), "01日", "31日")
- st = "税款所属期: " & rq1 & "至" & rq2
- With sh
- .[a2] = st
- .UsedRange.Offset(8).Clear
- .Columns(2).NumberFormatLocal = "@"
- With .[a9].Resize(m, 43)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- ActiveWindow.DisplayZeros = False
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|