3

I have a sheet named Finder at which I created a tool to search in other sheets (named #1, #2, etc). The problem I encountered with is that I can't use the INDIRECT function in some cases as described below:

 { = 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),... }

Conceptual form:

 { = 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),... }

I need to address a range in another sheets like below:

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

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

it's OK, but I can't use INDIRECT to make the formula dynamic:

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"),...

Thanks in advance


UPDATE:

Finder Sheet

The Finder tool contains many cells. The picture shows why I need to obtain a sheet name using ROW() function.

UPDATE 2:

#1 Sheet

The combobox in the Finder sheet has four items and uses $B$4 cell:

    1- Approximate Search
    2- Exact Search
    3- Full Index
    4- Specific Category

Here is the full code of the formula:

= 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 Answer 1

3

The problem is caused by use of ROW and COLUMN functions. These functions return "arrays" even when only a single value, e.g. {1} rather than 1. In some contexts that's not an issue but in other cases (like here), excel has a problem converting {1} to 1 and the formulas don't work.

One possible solution is to enclose all ROW and COLUMN functions in a function like MAX or SUM which will convert for you, e.g. instead of

ROW() - 5

use

SUM(ROW()) - 5

but a better way (and the one I recommend) is to use ROWS or COLUMNS functions (with "S" on the end), so if first formula is in Z6 use

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

those will both give you a value of 1 in Z6 itself but as you copy down or across they will increment by 1 each time (and they don't suffer the same drawback as ROW and COLUMN). This is a better solution anyway as it does away with your -5s and it's less susceptible to error should you delete or add rows or columns

Sign up to request clarification or add additional context in comments.

10 Comments

Thanks @barry houndini. I added a picture to demonstrate why I need to use ROW() function to address a sheet name. In fact, I'm trying to make a vocabulary bank. So I placed many words in #1, #2, ... sheets. In these sheets, each word has a unique number and placed in column A and the words are in the second column. (column B) I tried to solve the problem using SUM() and MAX(), but it didn't solve it.
I updated the question again and added the full code. Please take a look at it. Thanks
OK, I understood why you were using ROW but it causes a problem as I said....but don't you have the sheet numbers listed in column B, why can't you use those - that would be simpler than ROW, ROWS or any other way?
I really don't have any idea about using column B. The formula is used in C6, D6, F6, G6, ..., C7, D7, F7, G7 and so on. How can I obtain the current row?!
Your formula is using ROW()-5 in row 6, so that gives you 1....but in B6 you already have 1, so rather than using ROW()-5 (which is causing you problems anyway), why not just refer to B6? In the rest of column B you appear to have 2,3,4 etc. so that will work for every row
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.