Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Sumproject Run-time Error 13

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 & ")")
  #2   Report Post  
Posted to microsoft.public.excel.programming
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 & ")")


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Sumproject Run-time Error 13

Try the below...You already have added double quotes ....mTimeCriteria = """"
& mTimeCriteria & """". So you can remove the double double quotes mentioned
within the evaluate()


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

If this post helps click Yes
---------------
Jacob Skaria


"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 & ")")

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Sumproject Run-time Error 13

This is getting closer. Both your suggestions eliminated the Error message.
The formula is evaluating to 0. It should be 915 if I have everything
correct.

The formula in my spreadsheet which evaluated to 915 is:=SUMPRODUCT(
--(DataTime="First day of employment (Time 1)"),( DataQuestion1) )
Do you see something off in the way it is in the VBA format that would make
it correct?


"Jacob Skaria" wrote:

Try the below...You already have added double quotes ....mTimeCriteria = """"
& mTimeCriteria & """". So you can remove the double double quotes mentioned
within the evaluate()


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

If this post helps click Yes
---------------
Jacob Skaria


"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 & ")")

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Sumproject Run-time Error 13

You need to specify that the address inclusive of sheet name.... as below

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")

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

'OR' since you have only one condition you can use sumif() as below

MsgBox WorksheetFunction.SumIf(mTimeRange, mTimeCriteria, mQuestion1Range)


If this post helps click Yes
---------------
Jacob Skaria


"DogLover" wrote:

This is getting closer. Both your suggestions eliminated the Error message.
The formula is evaluating to 0. It should be 915 if I have everything
correct.

The formula in my spreadsheet which evaluated to 915 is:=SUMPRODUCT(
--(DataTime="First day of employment (Time 1)"),( DataQuestion1) )
Do you see something off in the way it is in the VBA format that would make
it correct?


"Jacob Skaria" wrote:

Try the below...You already have added double quotes ....mTimeCriteria = """"
& mTimeCriteria & """". So you can remove the double double quotes mentioned
within the evaluate()


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

If this post helps click Yes
---------------
Jacob Skaria


"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 & ")")



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Sumproject Run-time Error 13

Check one of your other messages.

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 & ")")


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
run time error 1004 general odbc error excel 2003 vba Mentos Excel Programming 5 January 24th 11 02:56 PM
Visual Basic Error Run Time Error, Type Mismatch Meg Partridge Excel Discussion (Misc queries) 12 September 10th 08 06:10 PM
Urgent!!! Run-time error '-2147024770 (8007007e)' Automation error [email protected] Excel Programming 3 May 28th 08 04:51 AM
Error handling error # 1004 Run-time error [email protected] Excel Programming 3 May 20th 08 02:23 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM


All times are GMT +1. The time now is 03:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"