简体   繁体   English

Excel公式根据条件将单元格值复制到列

[英]Excel Formula to copy cell value to a column based on condition

I'm looking to reformat my spreadsheet. 我想重新格式化我的电子表格。 Here's a small model of it: 这是它的一个小模型:

[  ][;9][10][  ]
[  ][  ][X1][Y1]
[  ][  ][X2][Y2]
[  ][;9][20][  ]
[  ][  ][X3][Y3]
[  ][  ][X4][Y4]
[  ][  ][X5][Y5]
[  ][;9][43][  ]
[  ][  ][X6][Y7]

How can I reformat it to look like this: 我如何将其重新格式化为如下所示:

[  ][;9][10][  ]
[10][  ][X ][Y ]
[10][  ][X2][Y2]
[  ][;9][20][  ]
[20][  ][X3][Y3]
[20][  ][X4][Y4]
[20][  ][X5][Y5]
[  ][;9][43][  ]
[43][  ][X6][Y7]

I was looking to use the if statement, but I'm not sure how to do two things: 1) include the empty cell before the ;9 2) update the value in the left most cell every time the value after the ;9 updates (it should include this value instead) 我一直在使用if语句,但不确定如何做两件事:1)在; 9之前包含空单元格2)每次; 9之后的值更新时,都在最左侧的单元格中更新值(它应改为包含此值)

UPDATE: So I've been trying the answers, but it gives me an error. 更新:所以我一直在尝试答案,但这给我一个错误。 It turns out I have an extra line in my spreadsheet I didn't notice before. 事实证明,我的电子表格中还有一条以前没有注意到的行。

在此处输入图片说明

So I'm trying this and it's close to working. 因此,我正在尝试此操作,并且接近工作。 However, I'm actually looking for it to change dynamically if C1 changes number. 但是,我实际上正在寻找如果C1更改数字可以动态更改的方法。

This works at the beginning: 这在开始时起作用: 在此处输入图片说明

But not after the value changes. 但在值更改后不会。 Here, it should have the value 22584: 在这里,它的值应该为22584:

在此处输入图片说明

This doesn't work either: 这也不起作用:

在此处输入图片说明

With the top ;9 in B1, put this into A1, 将B1中的最高;9放到A1中,

 =IF(ISBLANK(B1), LOOKUP(1E+99, C$1:C1), "")

Then fill down as necessary. 然后根据需要填写。

查询1E99

Your revised question might be better answered with the following in A1, 您可以使用A1中的以下内容更好地回答您的修订问题:

=IF(ISBLANK(B1), INDEX(C$1:C1, AGGREGATE(14, 6, ROW($1:1)/(B$1:B1=";9"), 1)), "")

I think it is more reliable (for cases when X and Y are numbers). 我认为它更可靠(对于X和Y是数字的情况)。

In A1: =IF(ISBLANK(B1),LOOKUP(";9",$B$1:B1,$C$1:C1),"") and fill down. 在A1中: =IF(ISBLANK(B1),LOOKUP(";9",$B$1:B1,$C$1:C1),"")并填写。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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