(1)sumif・sumifs関数
科目集計・月別集計は
エクセルでは
=SUMIF($B$3:$B$15,E3,$C$3:$C$15)
=SUMIFS($C$3:$C$15,$A$3:$A$15,">=2013/4/1",$A$3:$A$15,"<=2013/4/30")
VBAの科目集計・月別集計は
Sub keisan()
Dim i As Long
Dim kotae1 As Long
Dim kotae2 As Long
Dim kotae3 As Long
'科目集計
For i = 3 To 15
Select Case Cells(i, 2)
Case "商品"
kotae1 = kotae1 + Cells(i, 3)
Case "交通費"
kotae2 = kotae2 + Cells(i, 3)
Case "事務用品"
kotae3 = kotae3 + Cells(i, 3)
End Select
Next
Cells(3, 6) = kotae1
Cells(4, 6) = kotae2
Cells(5, 6) = kotae3
'月別集計
kotae1 = 0
kotae2 = 0
kotae3 = 0
For i = 3 To 15
Select Case Cells(i, 1)
Case "2013/04/01" To "2013/04/30"
kotae1 = kotae1 + Cells(i, 3)
Case "2013/05/01" To "2013/05/31"
kotae2 = kotae2 + Cells(i, 3)
Case "2013/06/01" To "2013/06/30"
kotae3 = kotae3 + Cells(i, 3)
End Select
Next
Cells(3, 8) = kotae1
Cells(4, 8) = kotae2
Cells(5, 8) = kotae3
End Sub