Good morning all,
I'm run into a bit of an issue with a workbook i'm writing.
I have a sumif formula pulling in indirect references which works when added to a cell in the workbook;
=SUMIFS(INDIRECT($C$16),INDIRECT(VLOOKUP("MONTH",$A$24:$C$28, 3,FALSE)),$F31,INDIRECT(VLOOKUP("Reporting Period",$A$24:$C$28, 3,FALSE)),$C$9)
This equates to;
=SUMIFS('HH Data'!$H$1:$H$1000000,'HH Data'!$D$1:$D$1000000,F31,'HH Data'!$F$1:$F$1000000,C9)
This formula is repeated on a monthly basis for a year i.e. F31 is April, F32 is May etc
I've tried to create this in VBA using the evaluate function as follows;
However, rather than return the same value, the evaluated formula returns '0'. Where am i going wrong?
Thanks in advance for any help.
I'm run into a bit of an issue with a workbook i'm writing.
I have a sumif formula pulling in indirect references which works when added to a cell in the workbook;
=SUMIFS(INDIRECT($C$16),INDIRECT(VLOOKUP("MONTH",$A$24:$C$28, 3,FALSE)),$F31,INDIRECT(VLOOKUP("Reporting Period",$A$24:$C$28, 3,FALSE)),$C$9)
This equates to;
=SUMIFS('HH Data'!$H$1:$H$1000000,'HH Data'!$D$1:$D$1000000,F31,'HH Data'!$F$1:$F$1000000,C9)
This formula is repeated on a monthly basis for a year i.e. F31 is April, F32 is May etc
I've tried to create this in VBA using the evaluate function as follows;
Code:
Sub Evaluate_All_Consumption()
Worksheets("HG - Elec").Select
With ActiveSheet
'1st Year
'Meter address
Meter_Address = .Range("C16").Value
'Month address
Month_Address = .Range("C26").Value
'Reporting Period address
Reporting_Period = .Range("C24").Value
Reporting_Period_Query = .Range("C9").Value
For x = 1 To 12
Month_Query = .Range("F30").Offset(x, 0).Value
Test_Value = Evaluate("=SumIfs(" & Meter_Address & ", " & Month_Address & ", " & Month_Query & ", " & Reporting_Period & ", " & Reporting_Period_Query & ")")
Next x
End With
End Sub
However, rather than return the same value, the evaluated formula returns '0'. Where am i going wrong?
Thanks in advance for any help.