mikejo
09-23-2023, 03:31 AM
Hi,
I am trying to add values to a range. Earlier I used to give a formula to first cell and extend, but I was required to set calculation to automatic in order to process those cells and it started to run too slow. I am trying to add the values to an array and then add the array back as values, but I am getting a mismatch error for a worksheetfunction.sumproduct and I can't figure the cause. Any help would be appreciated!
For i = 1 to 3 ' this would be the column
For r = 3 To lRow
dataArray(r, 1) = WorksheetFunction.SumProduct( _
(Right(ws.Range("D2: D" & lRow), 4) = ws.Cells(2, lCol + 1 + i).Value) * _
(ws.Range("R2:R" & lRow) = ws.Cells(r, "B").Value) * _
(ws.Range("AC2:AC" & lRow)))
r, lCol, lRow are long, dataArray is variant: ReDim dataArray(1 To lRow, 1 To 1)
Error is run-time error 13 - type mismatch
Thanks!
I am trying to add values to a range. Earlier I used to give a formula to first cell and extend, but I was required to set calculation to automatic in order to process those cells and it started to run too slow. I am trying to add the values to an array and then add the array back as values, but I am getting a mismatch error for a worksheetfunction.sumproduct and I can't figure the cause. Any help would be appreciated!
For i = 1 to 3 ' this would be the column
For r = 3 To lRow
dataArray(r, 1) = WorksheetFunction.SumProduct( _
(Right(ws.Range("D2: D" & lRow), 4) = ws.Cells(2, lCol + 1 + i).Value) * _
(ws.Range("R2:R" & lRow) = ws.Cells(r, "B").Value) * _
(ws.Range("AC2:AC" & lRow)))
r, lCol, lRow are long, dataArray is variant: ReDim dataArray(1 To lRow, 1 To 1)
Error is run-time error 13 - type mismatch
Thanks!