Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

passing formula from vba to cell

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")

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

But it should be:

=IF(ISNUMBER(SEARCH("*trade-508-cd*",B2)),"1","0")

>Solution :

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…

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading