View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
aw aw is offline
external usenet poster
 
Posts: 19
Default function "sumproduct" in VBA environment

Dear Sir / Madam,

Could anyone can help to translate the worksheet function sumproduct (as
below) into VBA??


=SUMPRODUCT(--(yard="BSHKY"),--(ac_name="Yard Trucks"),amt)

Remark : Yard, ac_name & amt are pre-defined range.


My working as follow : (but run-time error 13 type mismatch appear)

Sub sp()
a = InputBox("Yard")
b = InputBox("A/C name")
MyAns = Application.WorksheetFunction.SumProduct((Range("y ard") = "a"),
(Range("ac_name") = "b"), Range("amt"))
End Sub

!!!Thank you so much!!!

Best rgds // aw

--
aw