我正在练习构建在单元格中用作公式的函数,并且似乎遇到了障碍。只要在单元格中使用时不返回字符串,下面的代码就可以工作。此代码非常适用于整数,甚至在我编写子代码以使用该函数时也适用于字符串。我似乎无法弄清楚为什么当我在单元格的公式中使用它时它会返回
Function bIsBlank(x As String) As String
Dim y As String
If x = "" Then 'check to see if it is blank
Exit Function
Else
y = Evaluate(x) 'solve the formula that is pulled in
If y = "0" Then 'check to see if formula equals zero
y = "" 'set to nothing if it is zero
End If
End If
'below is my attempt to fix it by adding quotes on either side of the string
'this did not work
y = Chr(34) & y & Chr(34)
'this seems to solve for a sub but not a formula in a cell for strings
bIsBlank = y
End Function
问题是我不需要使用评估功能。我引入的公式已经解决了。所以说我有一个解决“A”的vlookup。在代码中 X = "A" 不是我最初预期的字符串 vlookup(a1,a5:b10,2,0)