Excel中的Visual Basic在第二行推送下面的公式的一部分。如何将它保持在一条线上或使其在多条线上工作?
ActiveCell.FormulaR1C1 = "=IF(ISNUMBER(SEARCH(""*DUPLICATE*"",RC[+3])),""Duplicate"",IF(ISNUMBER(SEARCH(""*ABBREV*AM or PM*"",RC[+3])),""Prohibited Abbreviation"",IF(ISNUMBER(SEARCH(""*ABBREV*>*<*"",RC[+3])),""Prohibited Abbreviation"",IF(ISNUMBER(SEARCH(""*ABBREV*Q*"",RC[+3])),""Prohibited Abbreviation"",IF(ISNUMBER(SEARCH(""*ABBREV*U*IU*"",RC[+3])),""Prohibited Abbreviation"",IF(ISNUMBER(SEARCH(""*Out of Stock*"",RC[+3])),""CMOP Out of Stock"",IF(ISNUMBER(SEARCH(""*SIG TOO LONG*"",RC[+3])),""Sig Too Long To Process"",IF(ISNUMBER(SEARCH(""*CMOP STOC*"",RC[+3])),""Quantity"",IF(ISNUMBER(SEARCH(""MISSPELLIN*"",RC[+3])),""Misspelling"",IF(ISNUMBER(SEARCH(""*MANUF*B*ORDER*"",RC[+3])),""Manufacturer'S Backorder"",IF(ISNUMBER(SEARCH(""*EXPIRED ADDRES*"",RC[+3])),""Expired Address"",IF(ISNUMBER(SEARCH(""*NOT STOCKED*LOW USAGE*"",RC[+3])),""Not Stock-Low usage"",IF(ISNUMBER(SEARCH(""*PRODUCT D*C*"",RC[+3])),""Product Discontinued"",IF(ISNUMBER(SEARCH(""*REFRIG*PO BOX*"",RC[+3])),""Refrig Item/PO Box Address"",IF(ISNUMBER(SEARCH(""*CORRECT*RESUBMIT*"",RC[+3])),""Correct Qty & Resubmit"","" "")))))))))))))))"""
答案 0 :(得分:0)
您可以使用精心布置的引号,下划线和&符号在VBA编辑器中跨行分割公式文本:
Option Explicit
Sub Test()
ActiveCell.FormulaR1C1 = "=IF(15>10, " & _ '<~ quote, ampersand and underscore
"12345, " & _
"67890)"
End Sub
话虽这么说,ActiveCell
可能很棘手,你写出来的公式很复杂。您是否可以在设计中设计Select...Case
语句,以便为可能维护代码的人们提供更具可读性的体验?