Hi,
I just wanted to generate the report using the macro but something went wrong. Can any one assist please.
Sheet 1 contains the data. headers are the name of the ranges.
<tbody>
</tbody>
Sheet 2
<tbody>
</tbody>
Code that I've used:
Sub rep()
Dim Amt As Range
Dim Region As Range
Dim Pro_Type As Range
Dim I As Integer
For I = 9 To 12
If Cells(3, "B") = "Retail" Then
Cells(I, "C") = worksheetsfunction.SumIfs(Amt, Region, Cells(I, "B"), Pro_Type, "0")
Else
If Cells(3, "B") = "Project" Then
Cells(I, "C") = worksheetsfunction.SumIfs(Amt, Region, Cells(I, "B"), Pro_Type, "<>" & "0")
Else
Cells(I, "C") = worksheetsfunction.SumIfs(Amt, Region, Cells(I, "B"), Pro_Type, Cells(3, "B"))
End If
Next I
End Sub
I just wanted to generate the report using the macro but something went wrong. Can any one assist please.
Sheet 1 contains the data. headers are the name of the ranges.
<colgroup><col width="76" span="4" style="width:57pt"> </colgroup><tbody> </tbody> |
<tbody>
</tbody>
Sheet 2
a | b | c | |||
1 | |||||
2 | |||||
3 | Select type | This Contains Validation (Retail,Project,H,R,C) | |||
4 | |||||
5 | |||||
6 | |||||
7 | |||||
8 |
<tbody> </tbody> |
<tbody> </tbody> | |||
9 |
<tbody> </tbody> | ||||
10 |
<tbody> </tbody> | ||||
11 |
<tbody> </tbody> | ||||
12 |
<tbody> </tbody> |
<tbody>
</tbody>
Code that I've used:
Sub rep()
Dim Amt As Range
Dim Region As Range
Dim Pro_Type As Range
Dim I As Integer
For I = 9 To 12
If Cells(3, "B") = "Retail" Then
Cells(I, "C") = worksheetsfunction.SumIfs(Amt, Region, Cells(I, "B"), Pro_Type, "0")
Else
If Cells(3, "B") = "Project" Then
Cells(I, "C") = worksheetsfunction.SumIfs(Amt, Region, Cells(I, "B"), Pro_Type, "<>" & "0")
Else
Cells(I, "C") = worksheetsfunction.SumIfs(Amt, Region, Cells(I, "B"), Pro_Type, Cells(3, "B"))
End If
Next I
End Sub