Hello all,
I'm being a bit thick today...
I wish to use a sumproduct formula in VBA. Here is a sample that I've been using on a worksheet:-
When I use this code in VBA I get a type mismatch error:-
Can anyone spot what I'm doing incorrectly? Can I even use sumproduct in this manner? Thanks for any help
Dan
I'm being a bit thick today...
I wish to use a sumproduct formula in VBA. Here is a sample that I've been using on a worksheet:-
Holos Control.xls | |||||||||
---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | |||
123 | BS | NETCONSTRUCTIONCONTRACTSINPROG. | NetConstructionContractsinProg. | 0.001 | Y | TS | |||
124 | TS | NetInterest-External | NetInterest-External | 0.001 | Y | NetInterest-Interco | |||
125 | TS | NetInterest-Interco | NetInterest-Interco | 0.001 | Y | Y | |||
126 | TS | NoOracleequivalent | AbnormalItems-Gross | 0.000 | N | ||||
127 | TS | NoOracleequivalent | AbnormalP/(L)-95/96Restructuring | 0.000 | N | 1 | |||
Oracle to Holos F Mapping |
When I use this code in VBA I get a type mismatch error:-
Code:
Sub TestOfSumProduct()
Dim rngeA As Range, rngeC As Range, rngeE As Range
Dim strLine As String, strSheet As String, strFlag As String
Dim vResult As Variant
Set rngeA = shtOracleToHolosMap.Range("A1:A265")
Set rngeC = shtOracleToHolosMap.Range("C1:C265")
Set rngeE = shtOracleToHolosMap.Range("E1:E265")
strLine = "Net Interest - Interco"
strSheet = "TS"
strFlag = "Y"
vResult = WorksheetFunction.SumProduct((rngeC.Value = strLine) * _
(rngeA.Value = strSheet) * (rngeE.Value = strFlag))
End Sub
Can anyone spot what I'm doing incorrectly? Can I even use sumproduct in this manner? Thanks for any help
Dan