Excel – find a line based on the contents of a cell and copy content from another cell in that line to another cell in another line

huangapple go评论67阅读模式
英文:

Excel - find a line based on the contents of a cell and copy content from another cell in that line to another cell in another line

问题

我在前端开发方面有一些经验,但现在我正在尝试在Excel中找到一个解决方案,解决我遇到的情况。假设我有以下电子表格示例:

表格 Col.A Col.B Col.C
行1 aaaaa
行2 zzzzz
行3 bbbbb
行4
行5 aaaaa 11111 22222
行6 bbbbb 33333 44444

表格不像我期望的那样,这里有一张图片:
table

正如您所看到的,具有ID aaaaa和bbbbb的产品在电子表格中出现两次(始终在Col.A中)。一次它们没有特征(行1和3中的空Col.B和Col.C),但第二次它们确实具有一些特征。
我需要将这些特征(来自行5和6的Col.B和Col.C)复制到行1和3的Col.B和Col.C。

当然,我不能手动复制它们,因为表格有超过1500行,它们不是按顺序排列的。它还有其他我不需要的行,比如行2的zzzzz,它需要保持不变。

我考虑通过使用产品ID来识别行,然后将从找到产品ID的行复制到需要它的行中的Col.B和Col.C。类似于:
如果找到aaaaa且Col.B和Col.C不为空,则复制该行的Col.B和Col.C到找到aaaaa且Col.A和Col.C为空的行,但我不知道如何在Excel中实现这一点。
但可能有一些更好的解决方案,无论如何...

谢谢!

英文:

I have some experience in front end development, but now I'm trying to find a solution for a situation I'm having in Excel. Let's say I have the following example of a spreadsheet:

TABLE Col.A Col.B Col.C
Line.1 aaaaa
Line.2 zzzzz
Line.3 bbbbb
Line.4
Line.5 aaaaa 11111 22222
Line.6 bbbbb 33333 44444

The table is not looking as I expected so here's a picture:
table

As you can see, the products with ID aaaaa and bbbbb appear two times each in the spreadsheet (always in Col.A). One time they have no characteristics (empty Col.B and Col.C in lines 1 and 3), but the second time, they do have some characteristics.
I need to copy those characteristics (from Col.B and Col.C of line 5 and 6) to Col.B and Col.C of lines 1 and 3.

Of course, I cannot copy them manually because the table has over 1500 lines and they are not in order. It has other lines between the ones I need, like Line.2 with zzzzz which needs to stay as it is.

I'm thinking of somehow identifying the line by using the product id and then copy Col.B and Col.C from the line where it's found to the line where I need it. Something like:
if aaaaa is found & Col.B & Col.C are not empty, copy Col.B and Col.C from that line to the line where aaaa is found & Col.A & Col.C are empty, but I don't know how to make this in Excel.
But there probably are some better solutions, anyway...

Thank you!

答案1

得分: 0

Formula in cell E3:

=IFERROR(IF(ISBLANK(C3);VLOOKUP(B3;$K$3:$M$4;2;FALSE);C3);"NO VALUE FOUND")

Formula in cell F3:

=IFERROR(IF(ISBLANK(D3);VLOOKUP(B3;$K$3:$M$4;3;FALSE);D3);"NO VALUE FOUND")

英文:

I would use your solution. To achieve this you first have to make a lookup table with no blank values.

then make a formula that has a IFBLANK and a VLOOKUP function that looks up the value if a blank value is found.

i wrap this in an IFERROR in order to see that a certain value is not found in your Lookup table.

Formula in cell E3:

=IFERROR(IF(ISBLANK(C3);VLOOKUP(B3;$K$3:$M$4;2;FALSE);C3);"NO VALUE FOUND")

Formula in cell F3:

=IFERROR(IF(ISBLANK(D3);VLOOKUP(B3;$K$3:$M$4;3;FALSE);D3);"NO VALUE FOUND")

Excel – find a line based on the contents of a cell and copy content from another cell in that line to another cell in another line

huangapple
  • 本文由 发表于 2023年7月20日 20:39:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/76729983.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定