2012-12-10 89 views
2

我想寫一個excel if語句。我是使用Excel所有額外功能的新手。我正在使用名爲importXML()的函數。我正在嘗試檢查我正在使用的函數是否生成「#VALUE!」錯誤如下:Excel:檢查IF語句中的錯誤

if(
    importXML(B1,C1)!="#VALUE!" //check if no error generated, 
    importXML(B1,C1)//if no error is generated, use these cells in the function 
    importXML(A1,C1)//else use these cells in the function 
) 

這可能嗎?我是否正確使用excels if語句來檢查錯誤?

+0

這是在VBA或電子表格? – Mark

+0

暫時不使用excel,但嘗試'IF(importXML(B1,C1)<>「#VALUE!」,importXML(B1,C1),importXML(A1,C1))' –

+0

這是電子表格 – AnchovyLegend

回答

2

試試這個:

=IF(ISERROR(importXML(B1,C1)),value_if_true,value_if_false) 

ISERROR Function

+0

輝煌,這個工程很棒!謝謝! – AnchovyLegend

+0

@mhz不客氣。 iferror函數在你的庫中也非常方便,但是如果你的用戶可能有老版本的excel,那麼它的便攜性就會降低。 – nullrevolution