简体   繁体   中英

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)

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.

This works at the beginning: 在此处输入图片说明

But not after the value changes. Here, it should have the value 22584:

在此处输入图片说明

This doesn't work either:

在此处输入图片说明

With the top ;9 in B1, put this into 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,

=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).

In A1: =IF(ISBLANK(B1),LOOKUP(";9",$B$1:B1,$C$1:C1),"") and fill down.

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