[英]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. 我想根据第2行中的条目数获取日期(在本示例中为第1行,第2列)。我可以使用Count()获得条目数,从而得到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 由于我需要在第3行和第1列的单元格中使用日期,因此此公式可以解决硬编码的数字
=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 )
(计数公式不是真正的公式,它有太多R和C的东西)
Does anyone know what I could do instead? 有人知道我能做什么吗? I want to avoid having a row of IF conditions in the formula.
我想避免在公式中出现一行IF条件。
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): 为您的公式尝试以下操作(假设您的日期在第1行中):
=Index(R1,,count(R2))
To explain briefly: It will return a cell in row 1 (the "index"). 简要说明一下:它将返回第1行中的单元格(“索引”)。 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. 我们知道哪个单元格,因为
count(r2)
计算该行中有多少个单元格的信息,然后返回该列(第1行)中的单元格。
Use the Offset
function and COUNT
. 使用
Offset
功能和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. COUNT
函数确定第2行中有多少列(假设它们是连续的)中的数据。这里的第2行是硬编码的,因为没有迹象表明您需要否则。
=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. 此公式返回与单元格R1C1偏移0行(IOW,同一行)的单元格中的恢复数值,并通过Count函数偏移的列数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.