简体   繁体   English

寻求帮助以在 Excel 中表现出色

[英]Seeking help to excel in Excel

This pictures shows my table and formula's yield这张图片显示了我的表格和公式的产量

I have used following formula to extract result from a table.我使用以下公式从表格中提取结果。

Its working perfectly fine but I am hoping to level up my understanding of Excel formulas.它工作得很好,但我希望能提高我对 Excel 公式的理解。

The trouble is that I use IF in Excel way to often.问题是我经常在 Excel 中使用 IF 。

what I wanted to know is if its possible to use a different approach, something that can work similar to if but is perhaps more sophisticated.我想知道的是是否可以使用不同的方法,它的工作原理类似于 if 但可能更复杂。

=IF(OR(J2="08L",J2="08R"),IF(ISNUMBER(MATCH(LEFT(I2,3),'SID separations'!$D$34,0)),"LAM",IF(ISNUMBER(MATCH(LEFT(I2,3),'SID separations'!$D$35:$E$35,0)),"West",IF(ISNUMBER(MATCH(LEFT(I2,3),'SID separations'!$D$36:$G$36,0)),"East",IF(ISNUMBER(MATCH(LEFT(I2,3),'SID separations'!$D$37,0)),"SFD",NA())))),0)

I very much appreciate any help.我非常感谢任何帮助。

Now that there is an example, I think this is a good question.现在有一个例子,我认为这是一个很好的问题。 You've recognised that your formula is fairly messy and also can't be easily expanded if there are more routes.您已经认识到您的公式相当混乱,而且如果有更多路线,也无法轻松扩展。

The problem is that Excel is very good for searching for a value in a single row or column, but not as good for searching for a value in a block of data.问题是 Excel 非常适合在单行或单列中搜索值,但不太适合在数据块中搜索值。

You can simplify this problem by creating an additional column that has each entire route in a single cell.您可以通过创建一个附加列来简化此问题,该列在单个单元格中包含每个完整的路线。 You can do this just by concatenating values.您可以通过连接值来做到这一点。 In your example, use column H:在您的示例中,使用列 H:

=B2&" "&C2&" "&D2&" "&E2&" "&F2&" "&G2

This will create a string with the entire route in a single cell.这将在单个单元格中创建一个包含整个路线的字符串。 Spaces are added in between each part of the route to make sure you don't accidentally create a sequences of letters that matches part of another route.在路线的每个部分之间添加空格,以确保您不会意外创建与另一路线的部分匹配的字母序列。 It doesn't matter if there are blank cells, there will just be some extra spaces at the end which doesn't matter.是否有空白单元格无关紧要,最后会有一些额外的空格,这无关紧要。 Fill this down the column to get the entire path for each route in a single cell.将其填入列中以获取单个单元格中每条路线的完整路径。

Then, you can create a formula that tries to find the 3 letters anywhere in any of the full routes.然后,您可以创建一个公式,尝试在任何完整路线中的任何位置查找 3 个字母。

=INDEX($A$2:$A$5,MATCH("*"&left(I2,3)&"*",$H$2:$H$5,0))

This formula is basically a deconstructed vlookup.这个公式基本上是一个解构的 vlookup。 It determines where the 3 characters can be found in column H, then gives back the corresponding value from column A.它确定可以在 H 列中找到 3 个字符的位置,然后返回 A 列中的相应值。

The MATCH function tries to find the left 3 characters of I2 in column H. The MATCH function normally tries to find a complete exact match (with the last parameter being equal to 0), but we can just add wildcards to the search value. MATCH 函数尝试在 H 列中查找 I2 的左侧 3 个字符。 MATCH 函数通常尝试查找完全精确匹配(最后一个参数等于 0),但我们可以只在搜索值中添加通配符。 The MATCH function then returns the index of the range where it was found. MATCH 函数然后返回找到它的范围的索引。 Ie, if it was found in the 2nd cell of the range H2:H5, it returns the number 2.即,如果在 H2:H5 范围的第二个单元格中找到它,则返回数字 2。

The INDEX function then just gets a value from a range based on an index. INDEX 函数然后只是从基于索引的范围中获取一个值。 In this case, it will get the 2nd value from range A2:A5.在这种情况下,它将从范围 A2:A5 中获取第二个值。

在此处输入图片说明

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

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