|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
参与一下。。。- Sub ykcbf() '//2023.12.30
- Dim arr, brr, wb
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- p = ThisWorkbook.Path
- f = p & "\申请单明细.xlsx"
- Set sh = ThisWorkbook.Sheets("申请单")
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets("申请明细")
- r = .Cells(Rows.Count, 1).End(3).Row
- num = Val(Mid(.Cells(r, 2), 3))
- End With
- ReDim brr(1 To 1000, 1 To 26)
- On Error Resume Next
- With sh
- r = .UsedRange.Find("合计").Row
- arr = .UsedRange
- For i = 7 To r - 1
- If arr(i, 1) <> Empty Then
- m = m + 1
- brr(m, 1) = arr(2, 16)
- brr(m, 2) = "xs" & Format(num + m, "00000")
- brr(m, 3) = arr(3, 2)
- brr(m, 4) = arr(r + 2, 2)
- brr(m, 5) = arr(4, 2)
- brr(m, 6) = arr(4, 11)
-
- For j = 2 To 9
- brr(m, j + 5) = arr(i, j)
- Next
- brr(m, 15) = arr(i, 1)
- For j = 10 To 16
- brr(m, j + 6) = arr(i, j)
- Next
- End If
- Next
- End With
- With wb.Sheets("申请明细")
- r = .Cells(Rows.Count, 1).End(3).Row
- With .Cells(r + 1, 1).Resize(m, 23)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- wb.Close 1
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|