无法在数组公式中实现INDIRECT()

时间:2013-12-01 06:44:16

标签: excel excel-formula array-formulas

我有一张名为 Finder 的工作表,我在其中创建了一个工具来搜索其他工作表(名为#1,#2等)。我遇到的问题是在某些情况下我不能使用INDIRECT函数,如下所述:

 { = IF(Finder!$B$4 = 1,
        INDEX(INDIRECT("'#" & (ROW() - 5) & IF(MOD(COLUMN(), 3) = 0, "'!$A$2:$A$100", "'!$B$2:$B$100")),
              SMALL(IF(ISERROR(SEARCH(Finder!$F$4, '#1'!$B$2:$B$100)),
                       "",
                       ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100")) - MIN(ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100"))) + 1),
                    INT(COLUMN() / 3)),
              1),
        IF(Finder!$B$4 = 2,
           INDEX(INDIRECT("'#" & (ROW() - 5) & "'!" & IF(MOD(COLUMN(), 3) = 0, "$A$2:$A$100", "$B$2:$B$100")),
                 SMALL(IF(Finder!$F$4 = '#1'!$B$2:$B$100,
                          ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100")) - MIN(ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100"))) + 1,
                          ""),
                       INT(COLUMN() / 3)),
                 1),... }

概念形式:

 { = IF(Finder!$B$4 = 1,
        INDEX(using INDIRECT to address a range in another sheet successfully,
              SMALL(IF(ISERROR(SEARCH(cannot use INDIRECT here!)),
                       "",
                       Desired value),
                    Desired item),
              1),
        IF(Finder!$B$4 = 2,
           INDEX(using INDIRECT to address a range in another sheet successfully,
                 SMALL(IF(cannot use INDIRECT here!,
                          Desired value,
                          ""),
                       Desired item),
                 1),... }

我需要在下面的其他工作表中解决范围:

SMALL(IF(ISERROR(SEARCH(Finder!$F$4, '#1'!$B$2:$B$100)),...

SMALL(IF(Finder!$F$4 = '#1'!$B$2:$B$100,...

没关系,但是我不能使用INDIRECT使公式动态化:

SMALL(IF(ISERROR(SEARCH(Finder!$F$4, INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100"))),...

SMALL(IF(Finder!$F$4 = INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100"),...

提前致谢


更新:

Finder Sheet

Finder工具包含许多单元格。图为我需要使用ROW()函数获取工作表名称的原因。

更新2:

#1 Sheet

Finder表中的组合框有四个项目,使用$ B $ 4单元格:

    1-近似搜索
    2-精确搜索
    3-完整索引
    4-特定类别

以下是公式的完整代码:

= IF(ISERROR(IF(Finder!$B$4 = 1,
                INDEX(INDIRECT("'#" & (ROW() - 5) & IF(MOD(COLUMN(), 3) = 0, "'!$A$2:$A$100", "'!$B$2:$B$100")),
                      SMALL(IF(ISERROR(SEARCH(Finder!$F$4, '#1'!$B$2:$B$100)),
                               "",
                               ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100")) - MIN(ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100"))) + 1),
                            INT(COLUMN() / 3)),
                      1),
                IF(Finder!$B$4 = 2,
                   INDEX(INDIRECT("'#" & (ROW() - 5) & "'!" & IF(MOD(COLUMN(), 3) = 0, "$A$2:$A$100", "$B$2:$B$100")),
                         SMALL(IF(Finder!$F$4 = '#1'!$B$2:$B$100,
                                  ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100")) - MIN(ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100"))) + 1,
                                  ""),
                               INT(COLUMN() / 3)),
                         1),
                   IF(Finder!$B$4 = 3,
                      IF(MOD(COLUMN(), 3) = 0,
                         20 * (ROW() - 6) + COLUMN() / 3,
                         INDIRECT(ADDRESS(INT(COLUMN() / 3) + 1, 2, 1, , "#" & (ROW() - 5)))),
                      INDEX(INDIRECT("'#" & (ROW() - 5) & "'!" & IF(MOD(COLUMN(), 3) = 0, "$A$2:$A$100", "$B$2:$B$100")),
                            SMALL(IF(Finder!$F$4 = '#1'!$I$2:$I$100,
                                     ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100")) - MIN(ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100"))) + 1,
                                     IF(ISERROR(SEARCH(Finder!$F$4 & ",", '#1'!$I$2:$I$100)),
                                        IF(ISERROR(SEARCH("," & Finder!$F$4, '#1'!$I$2:$I$100)),
                                           IF(ISERROR(SEARCH(", " & Finder!$F$4, '#1'!$I$2:$I$100)),
                                              "",
                                              ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100")) - MIN(ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100"))) + 1),
                                           ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100")) - MIN(ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100"))) + 1),
                                        ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100")) - MIN(ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100"))) + 1)),
                                  INT(COLUMN() / 3)),
                            1))))),
     " ",
     IF(Finder!$B$4 = 1,
        INDEX(INDIRECT("'#" & (ROW() - 5) & IF(MOD(COLUMN(), 3) = 0, "'!$A$2:$A$100", "'!$B$2:$B$100")),
              SMALL(IF(ISERROR(SEARCH(Finder!$F$4, '#1'!$B$2:$B$100)),
                       "",
                       ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100")) - MIN(ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100"))) + 1),
                    INT(COLUMN() / 3)),
              1),
        IF(Finder!$B$4 = 2,
           INDEX(INDIRECT("'#" & (ROW() - 5) & "'!" & IF(MOD(COLUMN(), 3) = 0, "$A$2:$A$100", "$B$2:$B$100")),
                 SMALL(IF(Finder!$F$4 = '#1'!$B$2:$B$100,
                          ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100")) - MIN(ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100"))) + 1,
                          ""),
                       INT(COLUMN() / 3)),
                 1),
           IF(Finder!$B$4 = 3,
              IF(MOD(COLUMN(), 3) = 0,
                 20 * (ROW() - 6) + COLUMN() / 3,
                 INDIRECT(ADDRESS(INT(COLUMN() / 3) + 1, 2, 1, , "#" & (ROW() - 5)))),
              INDEX(INDIRECT("'#" & (ROW() - 5) & "'!" & IF(MOD(COLUMN(), 3) = 0, "$A$2:$A$100", "$B$2:$B$100")),
                    SMALL(IF(Finder!$F$4 = '#1'!$I$2:$I$100,
                             ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100")) - MIN(ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100"))) + 1,
                             IF(ISERROR(SEARCH(Finder!$F$4 & ",", '#1'!$I$2:$I$100)),
                                IF(ISERROR(SEARCH("," & Finder!$F$4, '#1'!$I$2:$I$100)),
                                   IF(ISERROR(SEARCH(", " & Finder!$F$4, '#1'!$I$2:$I$100)),
                                      "",
                                      ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100")) - MIN(ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100"))) + 1),
                                   ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100")) - MIN(ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100"))) + 1),
                                ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100")) - MIN(ROW(INDIRECT("'#" & (ROW() - 5) & "'!$B$2:$B$100"))) + 1)),
                          INT(COLUMN() / 3)),
                    1)))))

1 个答案:

答案 0 :(得分:3)

问题是由使用ROWCOLUMN函数引起的。即使只有一个值,例如,这些函数也会返回“数组”。 {1}而不是1.在某些情况下,这不是问题,但在其他情况下(如此处),excel将{1}转换为1并且公式无效。

一种可能的解决方案是将所有ROWCOLUMN函数包含在MAXSUM之类的函数中,该函数将为您转换,例如而不是

ROW() - 5

使用

SUM(ROW()) - 5

但更好的方法(也是我推荐的方法)是使用ROWSCOLUMNS函数(最后使用“S”),所以如果第一个公式在Z6使用

ROWS($Z$6:Z6)COLUMNS($Z$6:Z6)

这些都会在Z6中给你一个值1,但是当你向下或向下复制时,它们每次都会增加1(并且它们不会遇到与ROW和{{1}相同的缺点})。这是一个更好的解决方案,因为它消除了你的-5s,如果你删除或添加行或列,它不容易出错