【问题标题】:Compare text in Excel columns and then assign corresponding value to specific column比较 Excel 列中的文本,然后将相应的值分配给特定列
【发布时间】:2015-09-14 14:14:04
【问题描述】:

我在 Excel 工作表中有一些值,即 B、D 和 E 列中的值是:

**B**                       **C** **D**       **E**

Cryptography                  11    1         Applied Mathematics
Machine Learning              23    2         Analysis of Algorithms
Networks and Communication    26    3         Automata Theory
Networks and Communication    26    4         Artificial Intelligence
Robotics                      30    5         Biological Networks
Computer Graphics             10    6         Combinatorial Optimization
Data Mining                   12    7         Computability Theory
Combinatorial Optimization    6     8         Computational Complexity Theory
Applied Mathematics           ..    9         Computer Vision
Analysis of Algorithms        ..    10        Computer Graphics
Information Retrieval         ..    11        Cryptography
Artificial Intelligence       ..    12        Data Mining
Artificial Intelligence       ..    13        Data Structures
Programming Languages         ..    14        Databases
Data Mining                   ..    15        Digital Logic
Cryptography                  ..    16        Distributed Computing
Information Retrieval         ..    17        Evolutionary Computation
Machine Learning              ..    18        Human Computer Interaction
Machine Learning              ..    19        Image Processing
...                           ..    ..        ...
...                           ..    ..        ...
...                           ..    ..        ...

column C 是空的。

现在我必须将column B 中的值与column E 匹配,找到匹配的行,我必须从column D 复制相应的ID 并将其放入column C。而我已经在column C 中手动输入了一些值以便快速了解。

【问题讨论】:

  • VLOOKUP 是您正在寻找的。基本上,您给出要查找的内容的范围,与什么进行比较,并返回任何值。这正是它的用途。
  • @durbnpoisn - 在这种情况下,Vlookup() 可能不是最直接的选择,而不需要 OP 更改他的数据。 Vlookup() 的表格范围将从他想要返回的内容开始(D 列),then 是他查找的范围。他必须先切换 D 列和 E 列。

标签: excel text multiple-columns


【解决方案1】:

如果我理解正确,索引/匹配公式(比 Vlookup 稍微强大一点)应该可以正常工作:

=INDEX($D$1:$D$19,MATCH($B1,$F$1:$F$19,0))。 ENTER 并向下拖动。请注意将19 更改为数据范围的最后一行。

这将返回一个索引,即D1:D19 范围内的一个单元格。它首先会查找范围F1:F19 以匹配单元格B1 的值,并获取该行,然后使用Index() 中的该行返回该值。

编辑:如果出现错误,您可以将其包装在 Iferror() 函数中以输出一些文本。 IE。 =IfError(INDEX($D$1:$D$19,MATCH($B1,$F$1:$F$19,0)), $B1 & " not found")

Edit2:为什么我不使用 vlookup,如果它们是可比较的?因为您当前布置数据的方式实际上并不允许这样做(很容易,无论如何)。尝试自己设置它,你会看到:=Vlookup(B1,d1:F19,1)...没有意义。你需要先重新排列你的数据,然后把 D 列的数字放在 G 中,然后这个就可以了:=VLOOKUP(B1,F1:G19,2,FALSE)

【讨论】:

  • @BruceWayne--非常感谢
  • @user5313087 - 不客气!您的问题实际上很好地展示了Vlookup() 的一些限制,并展示了如何使用更“强大”的索引/匹配来做基本相同的事情,只是具有更大的灵活性。
  • @BruceWayne--再次感谢
猜你喜欢
  • 1970-01-01
  • 2012-05-31
  • 1970-01-01
  • 1970-01-01
  • 2020-05-18
  • 1970-01-01
  • 2021-12-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多