简体   繁体   中英

Assign a cell based on the result of another formula

I want to get a date (in this example row 1, col 2) depending on the number of entries in row 2. I can get the Number of entries with Count() which gives me 2.

Since I need the date in the cell in row 3 and column 1 this formula would do the trick with hard coded numbers

=R(-2)C(1)

But the following formula does not like to get the second number from a formula. To simplify the formula I have the result of count in the cell below. I tried to use

=R(-2)C(R(1)C)

This results in a reference error. (The count formula is not the real one, it had too many R and C stuff )

Does anyone know what I could do instead? I want to avoid having a row of IF conditions in the formula.

I try to make it clearer:

|2015-01-01|2015-02-01|2015-03-01|
|   1634   |   214    |          |
|=formula()|          |          |
|=count(row2)|        |          |

where formula() = Date_from_row1_where_last_value_in_row_2

Try this for your formula (assuming your Dates are in row 1):

=Index(R1,,count(R2))

To explain briefly: It will return a cell in row 1 (the "index"). We know which cell, because the count(r2) counts how many cells have info in that row, then returns the cell in that column, row 1.

Use the Offset function and COUNT . The COUNT function determines how many columns (assumed they are contiguous) have data in Row 2. Row 2 here is hardcoded, since there is no indication that you need it to be otherwise.

=OFFSET(R1C1,0,COUNT(R2)-1)

This formula returns the restulting value in the cell which is offset 0 rows (IOW, the same row) as cell R1C1, and the # of columns offset by the Count function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM