View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
barry barry is offline
external usenet poster
 
Posts: 116
Default sumproduct or sumif in vba

Hi

If you mean you want to use the SumIf function in VBA then yes you can. One
way is with the Evaluate function which will also allow you to build the
string from variables your user can set. Example would be:

strCriteriaRange = "Sheet1!A1:A10"
strCriteriaValue = "a"
strSumRange = "Sheet1!B1:B10"


MsgBox Evaluate("sumif(" & strCriteriaRange & ",""" & strCriteriaValue &
"""," & strSumRange & ")")

This will return the same value as if you put
=SumIf(Sheet1!A1:A10,"a",Sheet1!B1:B10) into a cell in the spreadsheet.

HTH

Barry


"hellZg8" wrote:

I'm taking a long shot here but my question is
can sumproduct or sumif be used in VBA with a User filling in the blanks
with selections or text he/she has entered?