I have a pretty simple Macro but for the life of me, can't figure out why I keep on getting type mismatch. I have tried other versions of the formula and same issue.
In one worksheet,I have:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set Rng2 = Target
Call Sub1
End Sub
In the workbook, I have a module that has:
Option Explicit
Public Rng2 As Range, Rng1 As Range
Sub Sub1()
Set Rng1 = Rng2.Offset(0, -2)
'Debug.Print Evaluate("=SumProduct(--(Rng1 > 0), Rng1, Rng2)")
'Debug.Print [SUM(if(Rng1 > 0, Rng1 * Rng2))]
Debug.Print Application.WorksheetFunction.SumProduct(--(Rng1 > 0), Rng1, Rng2)
End Sub
None of those work.
Thanks!
好的,有人给了我答案,答案是:
Evaluate("=SUM(if(" & rng1.Address & "> 0," & rng1.Address & "*" & rng2.Address & "))")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.