[英]In MS Excel look for the previous cell that is a number in a column
For the same company (in this case Company A), I want to change the "NA" to the last available number.对于同一家公司(在本例中为公司 A),我想将“NA”更改为最后一个可用的号码。 For example, cell D3 and D4 are NA, so I want it both change to last available number (which is "1" in cell D2).
例如,单元格 D3 和 D4 是 NA,所以我希望它都更改为最后一个可用数字(在单元格 D2 中为“1”)。 If they are different company (like cell B7 and B6), then return the original "NA".
如果他们是不同的公司(如单元格 B7 和 B6),则返回原始的“NA”。
I tired =IF(C3= "NA", INDEX(C$2:C$11,MATCH(TRUE,ISNUMBER(C$2:C$11),0),1),C3)
, but it does not work as it returns #N/A.我厌倦了
=IF(C3= "NA", INDEX(C$2:C$11,MATCH(TRUE,ISNUMBER(C$2:C$11),0),1),C3)
,但它不起作用,因为它返回 #不适用。 Please can anyone help?请问有人可以帮忙吗? Thanks!
谢谢!
It seems to work for me though?它似乎对我有用? Recreated the data for company A and replaced "," for ";"
为 A 公司重新创建了数据,并将“,”替换为“;” as it is the separator I use.
因为它是我使用的分隔符。 Additionally I removed the spaces in the formula as I never use them in Excel.
此外,我删除了公式中的空格,因为我从未在 Excel 中使用它们。
As a result the formula gives the wanted result.结果,公式给出了想要的结果。
Does your Excel support the formulas you are trying to use?您的 Excel 是否支持您尝试使用的公式?
The column codes of your verbal description do not match the column codes of your screenshot.您的口头描述的列代码与屏幕截图的列代码不匹配。 So just to be clear, in the following answer I will refer to the column codes as given in your screenshot.
所以为了清楚起见,在下面的答案中,我将参考屏幕截图中给出的列代码。
The formula that you included does compute the result for me, by the way it is set up, it does not calculate what you described verbally.您包含的公式确实为我计算了结果,通过它的设置方式,它不会计算您口头描述的内容。
In its form as written in your question, the formula ignores the company name and when faced with an 'NA' value, it returns the first number it finds starting from the top .在您的问题中所写的形式中,该公式忽略了公司名称,当遇到“NA”值时,它会返回从 top 开始找到的第一个数字。
If I understand correctly, you want the formula to only take into consideration numbers associated with the same company name in column A, and when faced with 'NA', return the "most recent" number it finds for that company starting from the current row going up (given that date values are in order).如果我理解正确,您希望公式仅考虑与 A 列中相同公司名称关联的数字,并且在遇到“NA”时,返回从当前行开始为该公司找到的“最新”数字上升(假设日期值是有序的)。
The following formula incorporates those features when pasted into cell D2:以下公式在粘贴到单元格 D2 时包含这些功能:
=IFERROR(INDEX(FILTER($C$2:$C2,($A$2:$A2=$A2)*(ISNUMBER($C$2:$C2))),SUM(($A$2:$A2=$A2)*(ISNUMBER($C$2:$C2)))),"NA")
With this solution, the company names do not have to be in order, yet the date values do.使用此解决方案,公司名称不必按顺序排列,但日期值却可以。 The formula can be adjusted for cases where neither company names, nor date values are in order.
对于公司名称和日期值都不按顺序排列的情况,可以调整公式。
Note that the FILTER function is only available in Excel for Microsoft 365 and Excel 2021. In Excel 2019, Excel 2016 and earlier versions, it is not supported. Note that the FILTER function is only available in Excel for Microsoft 365 and Excel 2021. In Excel 2019, Excel 2016 and earlier versions, it is not supported.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.