|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 ykcbf1100 于 2024-1-29 19:09 编辑
参与一下,代码以附件为准。- Sub ykcbf() '//2024.1.29
- Dim arr, brr, d
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("Scripting.Dictionary")
- Set sh = ThisWorkbook.Sheets("增发工资文件")
- arr = sh.UsedRange
- For i = 1 To UBound(arr)
- s = arr(i, 2) & "|" & arr(i, 3)
- If arr(i, 2) <> Empty Then
- If Not d.exists(s) Then
- m = m + 1
- d(s) = Array(m, arr(i, 2), arr(i, 3), arr(i, 4))
- Else
- t = d(s)
- t(3) = t(3) + arr(i, 4)
- d(s) = t
- End If
- End If
- Next
- On Error Resume Next
- p = ThisWorkbook.Path
- f = p & "\代发工资文件.xls"
- Set wb = Workbooks.Open(f, 0)
- With wb.Sheets(1)
- arr = .UsedRange
- If arr(i, 2) <> Empty Then
- s = arr(i, 2) & "|" & arr(i, 3)
- If Not d.exists(s) Then
- m = m + 1
- d(s) = Array(m, arr(i, 2), arr(i, 3), arr(i, 4))
- Else
- t = d(s)
- t(s) = t(3) + arr(i, 4)
- d(s) = t
- End If
- End If
- .UsedRange = ""
- With .[a1].Resize(d.Count, 4)
- .Value = Application.Rept(d.Items, 1)
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- wb.Close 1
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|