Hi,
My sumif formula in i=1, y=24 and t=38 returns "0" value. I cant figure out why the formula returns 0 . Can someone help me solve this problem? Thanks
My sumif formula in i=1, y=24 and t=38 returns "0" value. I cant figure out why the formula returns 0 . Can someone help me solve this problem? Thanks
Code:
Sub SUMIFSLWFORMBRANDFE()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Const TOTALSROW = 73
Dim i As Integer, x As Integer, y As Integer, z As Integer, t As Integer, f As Integer
Dim lr As Long
lr = Worksheets("Source").Range("A" & Rows.Count).End(xlUp).Row
With Sheets("FE")
.Cells(TOTALSROW, 7) = WorksheetFunction.SumIf(Sheets("Source").Range("ci1:ci" & CStr(lr)), .Cells(TOTALSROW, 5), Sheets("Source").Range("av1:av" & CStr(lr)))
.Cells(TOTALSROW, 8) = WorksheetFunction.SumIf(Sheets("Source").Range("ci1:ci" & CStr(lr)), .Cells(TOTALSROW, 5), Sheets("Source").Range("aw1:aw" & CStr(lr)))
i = 1
.Cells(TOTALSROW + i, 7) = WorksheetFunction.SumIf(Sheets("Source").Range("Cb1:cb" & CStr(lr)), .Cells(TOTALSROW, 5), Sheets("Source").Range("av1:av" & CStr(lr)))
.Cells(TOTALSROW + i, 8) = WorksheetFunction.SumIf(Sheets("Source").Range("Cb1:cb" & CStr(lr)), .Cells(TOTALSROW, 5), Sheets("Source").Range("aw1:aw" & CStr(lr)))
For x = 2 To 23
.Cells(TOTALSROW + x, 7) = WorksheetFunction.SumIfs(Sheets("Source").Range("av1:av" & CStr(lr)), Sheets("Source").Range("Cg1:Cg" & CStr(lr)), .Cells(TOTALSROW + x, 6), Sheets("Source").Range("Cb1:cb" & CStr(lr)), .Cells(TOTALSROW + x, 5), Sheets("Source").Range("Cg1:cg" & CStr(lr)), .Cells(TOTALSROW + x, 6))
.Cells(TOTALSROW + x, 8) = WorksheetFunction.SumIfs(Sheets("Source").Range("aw1:aw" & CStr(lr)), Sheets("Source").Range("Cg1:Cg" & CStr(lr)), .Cells(TOTALSROW + x, 6), Sheets("Source").Range("Cb1:cb" & CStr(lr)), .Cells(TOTALSROW + x, 5), Sheets("Source").Range("Cg1:cg" & CStr(lr)), .Cells(TOTALSROW + x, 6))
Next x
y = 24
.Cells(TOTALSROW + y, 7) = WorksheetFunction.SumIf(Sheets("Source").Range("Cb1:cb" & CStr(lr)), .Cells(TOTALSROW, 6), Sheets("Source").Range("av1:av" & CStr(lr)))
.Cells(TOTALSROW + y, 8) = WorksheetFunction.SumIf(Sheets("Source").Range("Cb1:cb" & CStr(lr)), .Cells(TOTALSROW, 6), Sheets("Source").Range("aw1:aw" & CStr(lr)))
For z = 24 To 37
.Cells(TOTALSROW + z, 7) = WorksheetFunction.SumIfs(Sheets("Source").Range("av1:av" & CStr(lr)), Sheets("Source").Range("Cg1:Cg" & CStr(lr)), .Cells(TOTALSROW + z, 6), Sheets("Source").Range("Cb1:cb" & CStr(lr)), .Cells(TOTALSROW + z, 5), Sheets("Source").Range("Cg1:cg" & CStr(lr)), .Cells(TOTALSROW + z, 6))
.Cells(TOTALSROW + z, 8) = WorksheetFunction.SumIfs(Sheets("Source").Range("aw1:aw" & CStr(lr)), Sheets("Source").Range("Cg1:Cg" & CStr(lr)), .Cells(TOTALSROW + z, 6), Sheets("Source").Range("Cb1:cb" & CStr(lr)), .Cells(TOTALSROW + z, 5), Sheets("Source").Range("Cg1:cg" & CStr(lr)), .Cells(TOTALSROW + z, 6))
Next z
t = 38
.Cells(TOTALSROW + t, 7) = WorksheetFunction.SumIf(Sheets("Source").Range("Cb1:cb" & CStr(lr)), .Cells(TOTALSROW, 6), Sheets("Source").Range("av1:av" & CStr(lr)))
.Cells(TOTALSROW + t, 8) = WorksheetFunction.SumIf(Sheets("Source").Range("Cb1:cb" & CStr(lr)), .Cells(TOTALSROW, 6), Sheets("Source").Range("aw1:aw" & CStr(lr)))
For f = 39 To 51
.Cells(TOTALSROW + f, 7) = WorksheetFunction.SumIfs(Sheets("Source").Range("av1:av" & CStr(lr)), Sheets("Source").Range("Cg1:Cg" & CStr(lr)), .Cells(TOTALSROW + f, 6), Sheets("Source").Range("cb1:cb" & CStr(lr)), .Cells(TOTALSROW + f, 5), Sheets("Source").Range("Cg1:cg" & CStr(lr)), .Cells(TOTALSROW + f, 6))
.Cells(TOTALSROW + f, 8) = WorksheetFunction.SumIfs(Sheets("Source").Range("aw1:aw" & CStr(lr)), Sheets("Source").Range("Cg1:Cg" & CStr(lr)), .Cells(TOTALSROW + f, 6), Sheets("Source").Range("cb1:cb" & CStr(lr)), .Cells(TOTALSROW + f, 5), Sheets("Source").Range("Cg1:cg" & CStr(lr)), .Cells(TOTALSROW + f, 6))
Next f
End With
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
Last edited: