Excel执行宏的时候出错,说我语法错误,请问是哪错了。

Excel执行宏的时候出错,说我语法错误,请问是哪错了。ActiveCell.FormulaR1C1 = _
"=IF(RC[-1]=""不锈钢"",""不锈钢"",IF(RC[-42]=""定襄"",""寄售"",IF(AND(RC[-42]=""太原"",RC[-29]=""X80M""),""前移"",IF(AND(RC[-42]=""济南"",LEN(RC[-18])>LEN(SUBSTITUTE(RC[-18],""前移"",""""))),""前移"",IF(AND(RC[-42]=""济南"",LEN(RC[-18])>LEN(SUBSTITUTE(RC[-18],""撮合"",""""))),""前移"",IF(AND(RC[-42]=""天津"",RC[-32]=""F""),""前移"",IF(RC[-30]=""硅钢"",""前移"",IF(RC[-39]=""6340"",""寄售"",IF(RC[-39]="""& _
""寄售"",IF(RC[-39]=""6360"",""寄售"",""前移""))))))))))"

正确的语句:

ActiveCell.FormulaR1C1 = "=IF(RC[-1]=""不锈钢"",""不锈钢"",IF(RC[-42]=""定襄"",""寄售"",IF(AND(RC[-42]=""太原"",RC[-29]=""X80M""),""前移"",IF(AND(RC[-42]=""济南"",LEN(RC[-18])>LEN(SUBSTITUTE(RC[-18],""前移"",""""))),""前移"",IF(AND(RC[-42]=""济南"",LEN(RC[-18])>LEN(SUBSTITUTE(RC[-18],""撮合"",""""))),""前移"",IF(AND(RC[-42]=""天津"",RC[-32]=""F""),""前移"",IF(RC[-30]=""硅钢"",""前移"",IF(RC[-39]=""6340"",""寄售"",IF(RC[-39]=""寄售"",IF(RC[-39]=""6360"",""寄售"",""前移""))))))))))"

我选中CK1,执行后结果为:

=IF(CJ1="不锈钢","不锈钢",IF(AU1="定襄","寄售",IF(AND(AU1="太原",BH1="X80M"),"前移",IF(AND(AU1="济南",LEN(BS1)>LEN(SUBSTITUTE(BS1,"前移",""))),"前移",IF(AND(AU1="济南",LEN(BS1)>LEN(SUBSTITUTE(BS1,"撮合",""))),"前移",IF(AND(AU1="天津",BE1="F"),"前移",IF(BG1="硅钢","前移",IF(AX1="6340","寄售",IF(AX1="寄售",IF(AX1="6360","寄售","前移"))))))))))

追问

请问我的语法是哪错了?

温馨提示:答案为网友推荐,仅供参考
第1个回答  2017-09-29
""太原""双引号都多了。。。去掉一个试试。"太原"
相似回答