简体   繁体   English

将 IF(AND 公式分配给 VBA 中的单元格

[英]assign IF(AND formula to the cell in VBA

I am struggling to assign the formula I have to the cell using VBA.我正在努力使用 VBA 将我拥有的公式分配给单元格。 The code is like below :代码如下:

x.Sheets("Sheet2").Range("E2").Formula = "=IF(AND(B2>TIME(9;0;0);B2<TIME(18;0;0);ISNUMBER(SEARCH("CIXIS";C2)));"TRUE";"FALSE")"

But interestingly the macros does not accept any if formula.但有趣的是,宏不接受任何 if 公式。 I think it is because of the quotation mark but I used Char(34) , but no success.我认为这是因为引号的原因,但我使用了Char(34) ,但没有成功。 I even added double quotation mark, still not any success.我什至加了双引号,仍然没有任何成功。 I know that we should be able to assign formula using macros, what I am doing wrong?我知道我们应该能够使用宏分配公式,我做错了什么? Any help would highly appreciated.任何帮助将不胜感激。

x.Sheets("Sheet2").Range("E2").Formula = _
         "=IF(AND(B2>TIME(9,0,0),B2<TIME(18,0,0)," & _
         "ISNUMBER(SEARCH(""CIXIS"",C2))),""TRUE"",""FALSE"")"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM