|
再次更新。
- Sub ykcbf() '//2024.6.4 表头添加日期,日期按顺序排列
- Dim arr, brr
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- ReDim brr(1 To 10000, 1 To 100)
- bt = [{"代码","收盘"}]
- Set fso = CreateObject("scripting.filesystemobject")
- Set Sh = ThisWorkbook.Sheets("合并")
- p = ThisWorkbook.Path & ""
- For x = 1 To 31
- For Each f In fso.GetFolder(p).Files
- If LCase$(f.Name) Like "*.xls*" Then
- If InStr(f.Name, ThisWorkbook.Name) = 0 Then
- fn = fso.GetBaseName(f)
- If x = Val(Right(fn, 2)) Then
- n = n + 2
- m = 2
- rq = x
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets(1)
- arr = .UsedRange
- wb.Close False
- End With
- brr(1, n - 1) = x & "日"
- brr(2, n - 1) = bt(1)
- brr(2, n) = bt(2)
- For i = 2 To UBound(arr)
- If arr(i, 1) <> Empty Then
- m = m + 1
- brr(m, n - 1) = Format(arr(i, 1), "000000")
- brr(m, n) = arr(i, 2)
- End If
- Next
- Max = IIf(Max < m, m, Max)
- Exit For
- End If
- End If
- End If
- Next f
- Next
- With Sh
- .UsedRange.Clear
- .[a1].Resize(2, n).Interior.Color = 49407
- For col = 1 To n Step 2
- Columns(col).NumberFormat = "@"
- Next col
- With .[a1].Resize(Max, n)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- With .Font
- .Name = "微软雅黑"
- .Size = 11
- End With
- End With
- For col = 1 To n Step 2
- .Cells(1, col).Resize(, 2).Merge
- Next col
- ActiveWindow.DisplayZeros = False
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|