[英]passing formula from vba to cell
I am trying to pass formula in Excel cell using Excel VBA:我正在尝试使用 Excel VBA 在 Excel 单元格中传递公式:
Mt_1 = "trade-508-cd"
bpTargetRange.FormulaR1C1 = "=IF(ISNUMBER(SEARCH(""*""&Mt_1&""*"",RC[-1])),""1"",""0"")"
When running the above the cell is having folrmula:运行上述单元格时,单元格具有以下公式:
=IF(ISNUMBER(SEARCH("*"&@Mt_1&"*",B2)),"1","0")
But it should be:但它应该是:
=IF(ISNUMBER(SEARCH("*trade-508-cd*",B2)),"1","0")
Please, try the next code:请尝试下一个代码:
Dim Mt_1 As String: Mt_1 = "trade-508-cd"
bpTargetRange.Formula2R1C1= "=IF(ISNUMBER(SEARCH(""*" & Mt_1 & "*"",B2)),""1"",""0"")"
My answer supposes that Mt_1
is a VBA variable...我的回答假设
Mt_1
是一个 VBA 变量......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.