"I am having trouble getting the formulas you suggested to work. I am not sure where the problem is coming from. Could you look at the following spreadsheet and tell me where I am going wrong? The following pic shows Day 1 and AUX tables. In Day 1 cell B1 a Drivers name is entered. As you can see by the formula that you gave the B2 is for "Product" not the drivers name "David"."
Hi br,
The formulas provided above apply directly to the set of tables shown with them. In each of these tables, the target cell, containing the name of the driver for that day is cell B2 on the table for that day.
For Day 1, the driver is Huey, found in cell B2 of Table 1, and the cell reference to retrieve the information from that cell is =Table 1::B2
The formula in B2 of Aux uses INDIRECT to build that cell reference from the fixed text string "Table ", the calculated value ROW()-1, and the text string "::B2"
ROW() returns the number of the row in which the function sits. In B2, that's row 2, and ROW() returns 2. -1 subtracts 1 from that value, leaving 1. In B2, ROW()-1 returns 1.
The ampersand is the concatenation operator. It joins the value before it to the value following it. The result is a text string. in the INDIRECT part of the formula, there are two & operators, one after "Table ", the other after ROW()-1.
"Table " & ROW()-1 & "::B2" with the result of ROW()-1 as the value between the two text strings.
"Table " & 1 & "::B2" = "Table 1::B2"
INDIRECT( ) takes that text and converts it to the cell address that it represents.
B2: =IF(LEN(INDIRECT("Table "&ROW()-1&"::B2"))<1,"",INDIRECT("Table "&ROW()-1&"::B2"))
The first instance on the string in the formula is a test to see if there is anything in the target cell. If not, the formula returns a null string. If there is at least 1 character there, the second instance of INDIRECT is called on to return the name to B2 of the table Aux.
Compare your formula below:
B4: =IF(LEN(INDIRECT("Day 3"&ROW()-1&"::B2"))<1,"",INDIRECT("Day 3"&ROW()-1&"::B2"))
As shown, this is the formula in B4 of your Aux table. In Row 4, ROW() returns 4, and ROW()-1 returns 3.
So the three elements of the cell address constructed in INDIRECT are "Day 3", 3, and "::B2"
The cell being addressed is "Day 33::B2", cell B2 on the table named Day 33.
The error results from there being no table with that name.
The fix (to the table part of the reference) is to change the first text string to "Day " (including the space after the word Day).
The fix to replace Product with the driver name is to change "::B2" to ::B1"
To fit the names of your day tables and the location of the driver's name on each, your formula in B2 should read:
B2: =IF(LEN(INDIRECT("Day "&ROW()-1&"::B1"))<1,"",INDIRECT("Day "&ROW()-1&"::B1"))
Regards,
Barry