LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sumproduct in VBA Type Mismatch problem


DogLover;564101 Wrote:
Just wanting to count multiple criteria and plan to expand this function
once
I know it is error free. I think I have some format off or something,
please
help I get the message "type mismatch".

mquestion1range has numerical data which should sum if the
mTimeCriteria is
found to match.

Dim mTimeCriteria, mPositionCriteria As String
Dim mQuestion1Range, mTimeRange, mPositionRange As Range
Dim mFormula As String
Dim mCount As Long

mTimeCriteria = "First day of employment (Time 1)"
mPositionCriteria = "Registered Nurse"
Set mPositionRange = Worksheets("Data").Range("DataPosition")
Set mTimeRange = Worksheets("Data").Range("DataTime")
Set mQuestion1Range = Worksheets("Data").Range("DataQuestion1")J

MsgBox Evaluate("=SUMPRODUCT( --(mTimeRange= " & mTimeCriteria &
")*(mQuestion1Range) )")


Not looked too closely at this but what sticks out a mile is the Dim
statements. You may want to specify the data type of each variable
separately, otherwise those not explicitly typed will be variants:
Dim mTimeCriteria, mPositionCriteria As String
Dim mQuestion1Range, mTimeRange, mPositionRange As Range
becomes:
Dim mTimeCriteria As String, mPositionCriteria As
String
Dim mQuestion1Range As Range, mTimeRange As Range, mPositionRange As
Range
Still guessing.. I would have thought that perhaps you're looking for
the likes of this:
MsgBox Evaluate("=SUMPRODUCT(--(" & mTimeRange.Address
& " =""" & mTimeCriteria & """)*" & mQuestion1Range.Address & "
)")
instead of:
MsgBox Evaluate("=SUMPRODUCT( --(mTimeRange= " &
mTimeCriteria & ")*(mQuestion1Range) )")
Have you tried using SumProduct via:
Application.Worksheetfunction.Sumproduct
You supply ranges, strings etc. but you don't have to worry about
multiple quotation marks.


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=155665

Microsoft Office Help



 
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
Type Mismatch Problem DarrellK Excel Programming 3 February 8th 07 12:34 AM
Type Mismatch problem... Trevor Williams Excel Programming 3 February 5th 07 05:50 PM
Type mismatch problem Dan Excel Programming 7 May 31st 06 04:55 PM
Type Mismatch Problem Damien McBain[_2_] Excel Programming 2 May 20th 05 04:09 PM
Type mismatch problem? NooK[_45_] Excel Programming 3 August 4th 04 01:07 PM


All times are GMT +1. The time now is 02:31 PM.

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"