带索引/匹配的工作表函数

时间:2016-02-14 17:45:31

标签: excel indexing match worksheet-function

我相信我的语法错了,有人会介意指出这个问题吗?

提前致谢

 result = Application.WorksheetFunction.IfError(Application.WorksheetFunction.Index_
(Range("Sheet10!$AC$40:$AC$118"), Application.WorksheetFunction.Match(Range("Sheet10!E3"),_
 Range("Sheet10!$AD$40:$AD$118"), 0)), "")

1 个答案:

答案 0 :(得分:1)

IFERROR function不能用作WorksheetFunction object。只要没有错误,公式就会起作用,但是当s1 = s[:3] print s1 2 23 4 12 6 12 Name: "1stSerie", dtype: float64 s2 = s[4:7] s2.name='2ndSerie' print s2 2 51 4 90 6 112 Name: 2ndSerie, dtype: float64 s3 = s[8:] s3.name='3rdSerie' print s3 2 51 4 90 6 112 Name: 3rdSerie, dtype: float64 print pd.DataFrame({'a': s1, 'b': s2, 'c': s3}) a b c 2 23 51 51 4 12 90 90 6 12 112 112 进入播放状态时会停止以返回默认值(例如,零长度字符串)。

WorksheetFunction.IfError

您可以尝试使用Application.Evaluate method

Sub ject()
    Dim result As Variant
    'this works if a match is found
    result = Application.WorksheetFunction.IfError( _
                Application.WorksheetFunction.Index(Range("Sheet10!AC40:AC118"), _
                Application.WorksheetFunction.Match(Range("Sheet10!E3"), Range("Sheet10!AD40:AD118"), 0)), "")
    Debug.Print result
End Sub

通常,可以Sub jective() Dim result As Variant 'this works on match or no match result = Application.Evaluate("IFERROR(INDEX(Sheet10!AC40:AC118, " & _ "MATCH(Sheet10!E3, Sheet10!AD40:AD118, 0)), ""nothing"")") Debug.Print result End Sub Application.Index(...,但不需要WorksheetFunction.Index(...

当引用带字符串的静态单元格地址时,通常不需要 $ 绝对制造商,因为字符串不会改变。一个可能的例外是当你使用字符串用公式填充大量单元格时;没有得到评估单个公式的结果。