我希望有人能回答这个问题。我不认为这是可能的,但我想要做的是使用字符串作为标准来设置一个 if 函数。例如:
With ThisWorkbook.Worksheets("Sheet1")
stNumerator = .Cells(6, 3).Value
stDenominator = .Cells(6, 4).Value
If .Cells(7, 3) = "x" Then
stCriteria = stNumerator & " >0"
End If
If .Cells(8, 4) = "x" Then
stCriteria = stCriteria & " and " & stDenominator & " <>0"
End If
If stCriteria Then
.Cells(1, 1) = stNumerator / stDenominator
End If
所以stCriteria
应该等于stNumerator > 0 and stDenominator <>0