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

Hi all

I know there's been many threads regarding this subject, but I'm still
none the wiser as to why it is so difficult to get it to work
considering it can be selected from the (.) context menu.

I'm not a huge fan of nesting formula's, especially when it comes to
complex ones over hundreds/thousands of cells given the crappy
infrastructure I deal with, that said!

Can anyone give me a reasonably basic explanation as to why this does
not work as is throws up a Type Mismatch:

So as to give as clearer explanation as possible, here is what each
column has.

Column A = Year ( contains 2011 though to 2012 and running )
Column B = Month ( Numeric representation ( 1 = Jan ))
Columns F & G contain either a 0 or 1.


Sub Calc_Jan()

Dim Ssht As Worksheet, Tsht As Worksheet
Dim mySumA As Range, mySumB As Range, mySumF As Range, mySumG As Range
Dim c1 As Range, c2 As Range
Dim Anchor1 As Range, Anchor2 As Range
Dim myMth As String

Set Ssht = Sheets("KPI Input")
Set mySumA = Ssht.Range("$A$2:$A$2500") 'Numeric Cells
Set mySumB = Ssht.Range("$B$2:$B$2500") 'Numeric Cells
Set mySumF = Ssht.Range("$F$2:$F$2500") 'Numeric Cells
Set mySumG = Ssht.Range("$G$2:$G$2500") 'Numeric Cells

myMth = 1
Set Tsht = Sheets("KPI")
Set Anchor1 = Tsht.Range("$H$17:$H$21") 'Numeric Cells
Set Anchor2 = Tsht.Range("$H$24:$H$28") 'Numeric Cells

For Each c1 In Anchor1
If c1 < "" Then
With c1
..Offset(0, 1).Value = WorksheetFunction.SumProduct((mySumA = c1) *
(mySumB = myMth) * (mySumF 0))
End With
End If
Next c1

For Each c2 In Anchor2
If c2 < "" Then
With c2
..Offset(0, 1).Value = WorksheetFunction.SumProduct((mySumA = c2) *
(mySumB = myMth) * (mySumG 0))
End With
End If
Next c2

End Sub


TIA
Mick.
 
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
Sumproduct instead of SumifS in VBA (application.sumproduct) Majken Bilslev-Jensen Excel Programming 7 December 30th 10 05:56 PM
Sumproduct blkane Excel Worksheet Functions 3 October 20th 09 07:12 PM
Sumproduct with Condition OR Sumproduct with ADDRESS function - HE gholly Excel Discussion (Misc queries) 2 September 28th 09 05:07 PM
Conditional SUMPRODUCT or SUMPRODUCT with Filters Ted M H Excel Worksheet Functions 4 August 14th 08 07:50 PM
sumproduct? sumif(sumproduct)? David Excel Worksheet Functions 3 July 13th 07 07:06 PM


All times are GMT +1. The time now is 03:11 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"