|
楼主 |
发表于 2024-1-19 21:36
|
显示全部楼层
请问一下大神如果运行区域从i4:L15变更成f40:n51
工作表从柴油利润表变更成机械租赁利润表
22列条件从柴油支出变更称机械租赁支出
要修改那些关联代码呢?
我自己改了一版 可是结果为空能麻烦您帮忙看看吗?
Sub 利润统计()
Application.ScreenUpdating = False
Dim arr, brr, d
Set d = CreateObject("Scripting.Dictionary")
p = ThisWorkbook.Path & "\"
f = p & "\数据源.xlsx"
Set wb = Workbooks.Open(f, 0)
With wb.Sheets("出纳")
r = .Cells(Rows.Count, 10).End(xlUp).Row
arr = Range("a2:v" & r)
wb.Close False
End With
With Sheets("机械租赁利润表")
.Range("f40:n51") = Empty
br = .Range("a38:n51")
For j = 6 To 10
d(br(2, j)) = j
Next j
For i = 3 To UBound(arr)
If arr(i, 10) <> Empty Then
If IsDate(arr(i, 10)) Then
yf = Val(Month(arr(i, 10)))
If InStr(arr(i, 22), "机械租赁支出") Then
lh = d(Trim(arr(i, 21)))
If lh <> "" Then
br(yf + 2, lh) = br(yf + 2, lh) + arr(i, 19)
br(yf + 2, 13) = br(yf + 2, 13) + arr(i, 19)
End If
End If
End If
End If
Next i
.Range("a38:n51") = br
End With
Application.ScreenUpdating = True
MsgBox "OK!"
End Sub
|
|