Board logo

標題: (已解決)VBA裡面的公式可以分段寫嗎 [打印本頁]

作者: freeffly    時間: 2010-7-2 23:37     標題: (已解決)VBA裡面的公式可以分段寫嗎

本帖最後由 freeffly 於 2012-2-22 17:09 編輯

Range("J5") = _
        "=IF(LEFT(RC[-9],1)=""1"",IF(OR(RC[-8]=""甲醇"",RC[-8]=""甲醛"",RC[-8]=""酚""),""化學槽"",IF(OR(LEFT(RC[-8],2)=""EH"",LEFT(RC[-8],2)=""LK"",LEFT(RC[-8],2)=""NH"",LEFT(RC[-8],2)=""PH"",LEFT(RC[-8],2)=""SH"",LEFT(RC[-8],2)=""VH""),""原紙"",IF(LEFT(RC[-8],3)=""木材"",""木材"",""其他""))),IF(LEFT(RC[-9],1)=""3"",IF(LEFT(RC[-8],1)=""R"",""金屬"",""布料""),IF(LEFT(RC[-9],1)=""4"",IF(LEFT(RC[-8],6)=""AU-910"",""9103"",RIGHT(LEFT(RC[-8],7),4)),IF(LEFT(RC[-9],1)=""5"",IF(OR(LEFT(RC[-8],2)=""IP"",LEFT(RC[-8],2)=""NH"",LEFT(RC[-8],2)=""SH""),""水晶"",IF(LEFT(RC[-8],3)=""木材"",""木材"",IF(LEFT(RC[-8],3)=""鑽石"",""鑽石"",""其他""))),IF(LEFT(RC[-9],1)=""6"",""布料"",""其他"")))))"

上面這是一個公式,原本我想要讓他可以分行使用 _ 的方式處理,結果沒辦法執行,只能照原來的長度
請問公式可以分行嗎?
作者: victorl    時間: 2010-7-2 23:49

本帖最後由 victorl 於 2010-7-2 23:52 編輯

回復 1# freeffly


    Range("J5") = _
"=IF(LEFT(RC[-9],1)=""1"",IF(OR(RC[-8]=""甲醇"",RC[-8]=""甲醛"",RC[-8]=""酚""),""化學槽""," & _
"IF(OR(LEFT(RC[-8],2)=""EH"",LEFT(RC[-8],2)=""LK"",LEFT(RC[-8],2)=""NH"",LEFT(RC[-8],2)=""PH"",LEFT(RC[-8],2)=""SH"",LEFT(RC[-8],2)=""VH""),""原紙""," & _
"IF(LEFT(RC[-8],3)=""木材"",""木材"",""其他""))),IF(LEFT(RC[-9],1)=""3"",IF(LEFT(RC[-8],1)=""R"",""金屬"",""布料"")," & _
"IF(LEFT(RC[-9],1)=""4"",IF(LEFT(RC[-8],6)=""AU-910"",""9103"",RIGHT(LEFT(RC[-8],7),4)),IF(LEFT(RC[-9],1)=""5""," & _
"IF(OR(LEFT(RC[-8],2)=""IP"",LEFT(RC[-8],2)=""NH"",LEFT(RC[-8],2)=""SH""),""水晶"",IF(LEFT(RC[-8],3)=""木材"",""木材""," & _
"IF(LEFT(RC[-8],3)=""鑽石"",""鑽石"",""其他""))),IF(LEFT(RC[-9],1)=""6"",""布料"",""其他"")))))"
同文字串方式處理
作者: freeffly    時間: 2010-7-3 00:10


這種方式不會出現錯誤
謝謝喔!




歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)