View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Per Jessen[_2_] Per Jessen[_2_] is offline
external usenet poster
 
Posts: 703
Default Sumproject Run-time Error 13

Hi

I tried to split up your code a bit, and found that the line commented
out below is not needed:

Dim mTimeCriteria As String
Dim mQuestion1Range As Range, mTimeRange As Range
Dim MyFormula As String

mTimeCriteria = "First day of employment (Time 1)"
Set mTimeRange = Worksheets("Data").Range("DataTime")
Set mQuestion1Range = Worksheets("Data").Range("DataQuestion1")
'mTimeCriteria = """" & mTimeCriteria & """"
MyFormula = "=SUMPRODUCT( --(" & mTimeRange.Address & "= """ &
mTimeCriteria & """), " & mQuestion1Range.Address & ")"
Result = Evaluate(MyFormula)

MsgBox Result

Hopes this helps.
....
Per


On 20 Nov., 13:52, DogLover
wrote:
I have this code and am having trouble with the Sumproduct working. *I get a
Run-Time Error 13 and Type Mismatch message? *Can anyone help. *

Dim mTimeCriteria As String
Dim mQuestion1Range As Range, mTimeRange As Range

mTimeCriteria = "First day of employment (Time 1)"
Set mTimeRange = Worksheets("Data").Range("DataTime")
Set mQuestion1Range = Worksheets("Data").Range("DataQuestion1")

mTimeCriteria = """" & mTimeCriteria & """"
MsgBox Evaluate("=SUMPRODUCT( --(" & mTimeRange.Address & "= """ & _
mTimeCriteria & """), " & mQuestion1Range.Address & ")")