I am trying to pass formula in Excel cell using Excel VBA:
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")
CodePudding user response:
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...