View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default VBA SUM Function

You can also put the sumproduct formula in the worksheet

from
MyFormula = "Sumproduct(" & _
"--(" & CodeRange.Address(external:=true) & "=""" _
& .Range("K" & r).Value & """)," & _
"--(" & CriteriaRange.Address(external:=true) & "=""Y"")," & _
SumRange.Address(external:=true) & ")"

to (added equal sign in front of forumal)
MyFormula = "=Sumproduct(" & _
"--(" & CodeRange.Address(external:=true) & "=""" _
& .Range("K" & r).Value & """)," & _
"--(" & CriteriaRange.Address(external:=true) & "=""Y"")," & _
SumRange.Address(external:=true) & ")"
Range("A1").formula = Myformula


"Dave Peterson" wrote:

Got it working means that
Total = Application.Evaluate(MyFormula)
actually evaluated to the correct number?

If yes, then maybe something like after this line:

Total = Application.Evaluate(MyFormula)
..Range("X" & r).Value = total


joecrabtree wrote:

<<snipped

Thanks for all your help. Ive now got this working, and understand how
it works. However I havent been able to get an output, i.e. displayed
sumproduct value. For example how would I be able to get this to
display the outputs an output worksheet?

Thanks again,

Joe Crabtree


--

Dave Peterson