Hi,
I have the 2016 Excel version where Minifs is not available. Instead, I'm trying to use the aggregate function to identify the minimum value of range C1:C4 in Sheet1 if two criteria are met (Range B1:B4 in Sheet1 equals value in cell B1 and Range A1:A4 equals value in cell A1). I am able to get the correct result if I "print" the formula in a cell in Sheet1, but get a runtime error 13 (type mismatch) when I specify the ranges in vba. I've written the following code:
Sub test()
Sheets("Sheet2").Range("a1") = Application.Aggregate(15, 6, Sheets("Sheet1").Range("c1:c4") / ((Sheets("sheet1").Range("b1:b4") = Sheets("sheet1").Range("b1")) * (Sheets("sheet1").Range("a1:a4") = Sheets("sheet1").Range("a1"))), 1)
End Sub
Would greatly appreciate if someone could point out the error, as I've now completely exhausted Google searching for an answer.
Thanks!
I have the 2016 Excel version where Minifs is not available. Instead, I'm trying to use the aggregate function to identify the minimum value of range C1:C4 in Sheet1 if two criteria are met (Range B1:B4 in Sheet1 equals value in cell B1 and Range A1:A4 equals value in cell A1). I am able to get the correct result if I "print" the formula in a cell in Sheet1, but get a runtime error 13 (type mismatch) when I specify the ranges in vba. I've written the following code:
Sub test()
Sheets("Sheet2").Range("a1") = Application.Aggregate(15, 6, Sheets("Sheet1").Range("c1:c4") / ((Sheets("sheet1").Range("b1:b4") = Sheets("sheet1").Range("b1")) * (Sheets("sheet1").Range("a1:a4") = Sheets("sheet1").Range("a1"))), 1)
End Sub
Would greatly appreciate if someone could point out the error, as I've now completely exhausted Google searching for an answer.
Thanks!