Getting the First Cell NOT Containing Certain Text in Numbers

I have a table in Numbers, and I'm trying to get the value of the first cell that contains the character . In order to do so, I wanted to use MATCH(), but had no luck after I realized it could only traverse 2 dimensions. Instead, I've set up a table on another sheet that looks like so:

Table with which rows contain the character

The numbers at the far left are the row numbers of the rows in the table with the actual data. Row Contains Cell is exactly what it sounds like: whether or not that row contains the desired cell. To figure that out, I used MATCH() per row.

What I need to figure out now is how to find which row is not the wrong row. It would be easy to look for a cell that says not, but I need to find a cell with a variable value that is not equal to not. I want to find the row name (or value of the cell to the left, in column A) for that cell (in this case, 2) and the value of the cell itself in column B.

What would be the formula for Correct Row and Correct Column, given what I'm looking for?

I know people have already done this for Excel, but I can't figure it out for Numbers.

I'm open to solutions that require Applescript.


Solution 1:

As it turns out, I've figured it out. It did require Applescript. What I did was loop through the rows and selected the values in the row where "not" was not present in column B. Here's the Applescript I used via Automator:

on run {input, parameters}

    tell application "Numbers"
        tell table "Calculator 1" of sheet 2 of document of front window
            set aRange to "A2:A22"
            set bRange to "B2:B22"
            set aRows to the rows of range aRange
            set bRows to the rows of range bRange

            set correctRow to -1
            set correctCol to -1

            repeat with i from 1 to count of bRows
                set aCell to "A" & (i + 1)
                set bCell to "B" & (i + 1)

                if value of (cell bCell) is not "not" then
                    set correctRow to value of (cell aCell)
                    set correctCol to value of (cell bCell)
                end if
            end repeat

            set the value of (cell "C2") to correctRow
            set the value of (cell "C4") to correctCol
        end tell

        display dialog "Updated!"
    end tell

    return input
end run

Keep in mind that the cells I used are specific to my spreadsheet, but generally this method could be applied for any 2D MATCH() function.

  1. Create a table has the name of the each row in each row of the header column, and use the desired MATCH() function per row in this way (see the picture of the table in my question).
  2. Use this Applescript to loop through the MATCH() functions and find the correct row and column. Change "C2" to whichever cell will be your Correct Row and "C4" to whichever cell will be your Correct Column.
  3. Use the INDEX() function to get the value of the cell and put it into another cell, using the coordinates the Applescript calculated for you.