|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
在“合并资产负债表”工作表中黄色部分需要得到:
在合并调整分录工作表C列中,查找B列的代码,如果代码相同,就返回F列(资产方)或G列(负债及所有者权益方)得到的结果应与后面一列的sumif函数得到的结果一致。
我写的vba代码是:
Sub t2()
Dim Nextcol
Dim arr
Nextcol = Cells(5, 255).End(xlToLeft).Column
Cells(5, Nextcol + 1).Select
ActiveCell.FormulaR1C1 = "合并调整"
arr = Sheets(1).Range("a8:h" & Sheets(1).Range("a65536").End(xlUp).Row)
For d = 6 To 91
s = 0
If Cells(d, 2) <> "" Then
For c = 1 To UBound(arr)
If arr(c, 3) = Cells(d, 2) Then
If d < 56 Then
s = s + arr(c, 7)
Else
s = s + arr(c, 6)
End If
End If
Next
End If
Cells(d, Nextcol + 1) = s
Next
End Sub
[ 本帖最后由 fishingnet1982 于 2010-11-3 17:13 编辑 ] |
|