带字符串参数的VBA评估函数 [英] VBA Evaluate function with string arguments
本文介绍了带字符串参数的VBA评估函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此功能有效(它返回文本DK001位于ID范围内的行)
I have this function working ( It returns the row where the text DK001 sits in the ID range)
Found = Application.Evaluate("=IF(ID=""DK001"",ROW(ID),""x"")")
我想将搜索条件(例如DK001)作为字符串输入,例如
I would like to feed the searchcriteria (e.g. DK001) as a string, like
Found = Application.Evaluate("=IF(ID=SearchString,ROW(ID),""x"")")
我无法创建被接受为搜索条件的字符串.我需要您的帮助!我在做什么错了?
I fail in creating a string that is accepted as a search criteria. I need your help on this! What am I doing wrong?
此评估功能困扰着我....
This Evaluate function is haunting me ....
如果我现在想向该函数发送一个值(而不是字符串)怎么办?
What if I now wanted to send a value (not a string) to the function?
Found = Application.Evaluate("=IF(ID=1,ROW(ID),""x"")")
以上方法有效!
但是如果我希望它是像这样的变量
But if I want this to be a variable like
Found = Application.Evaluate("=IF(ID=MyValue,ROW(ID),""x"")")
那又是什么?
推荐答案
双精度"
将其包括为文字:
Double "
to include them as literals:
SearchString = "DK001"
Found = Application.Evaluate(""=IF(ID=""" & SearchString & """,ROW(ID),""x"")")
这篇关于带字符串参数的VBA评估函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文