Sub showMinimumValueForStatus(Status As String)
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Sheet1") '--->> adjust this to your needs
Dim rg As Range
Set rg = ws.UsedRange.Columns("A:B")
Dim x As Long
x = Application.WorksheetFunction.MinIfs(rg.Columns(2), rg.Columns(1), Status)
MsgBox "Minimum value of " & Status & " is " & x
End Sub
1条答案
按热度按时间eivgtgni1#
如果要在VBA中使用公式,必须通过
application.worksheetfunction
调用它:此外,您应该始终通过其工作表显式引用范围。否则将引用活动工作表。