Hi all - can anyone explain why the following code is returning an error2015 against the 'myVar=' expression?
The SumProduct expression is valid when entered in the spreadsheet as a formula. I thought I'd found the answer in thread707-1158104, hence the Evaluate command, but no joy. All is well in the Watch window up until the 'myVar='
Any ideas would be really helpful!
Just trying to get one cell working at the moment - here's the code...
Thanks folks,
Chris
The SumProduct expression is valid when entered in the spreadsheet as a formula. I thought I'd found the answer in thread707-1158104, hence the Evaluate command, but no joy. All is well in the Watch window up until the 'myVar='
Any ideas would be really helpful!
Just trying to get one cell working at the moment - here's the code...
Code:
Private Sub CommandButton1_Click()
Dim wbTemplate As Workbook
Dim wb1 As Workbook
Dim strLUProd As String
Dim intLookUpValue1 As Integer
Dim strLookUpValue2 As String
Dim rngLookUpRange1 As Range
Dim rngLookUpRange2 As Range
Dim rngLookUpRange3 As Range
Dim intLookUpCol As Integer
Dim intR As Integer
Dim intC As Integer
intR = 8
intC = 2
intLookUpCol = 2
Set wbTemplate = ThisWorkbook
Set wb1 = Workbooks.Open(wbTemplate.Worksheets("Source Data Files").Range("A5").Text)
strLUProd = wbTemplate.Worksheets("Arrears").Cells(2, intC)
Set rngLookUpRange1 = wb1.Worksheets("Possessions by Product-Months").Range("A6:A1000")
Set rngLookUpRange2 = wb1.Worksheets("Possessions by Product-Months").Range("B6:B1000")
Set rngLookUpRange3 = wb1.Worksheets("Possessions by Product-Months").Range("C6:C1000")
myVar = Application.Evaluate("SumProduct((rngLookUpRange1 = strLUProd) * (rngLookUpRange2 = wbTemplate.Worksheets(""poss"").cells(intR,1)) * (rngLookUpRange3))")
wbTemplate.Worksheets("poss").Cells(intR, intC).Value = myVar
End Sub
Thanks folks,
Chris