MS Excel:“MATCH()”如果查找数组太大,则不会找到包含文本的单元格 [英] MS Excel: "MATCH()" does not find cells containing text if lookup array is too large

查看:202
本文介绍了MS Excel:“MATCH()”如果查找数组太大,则不会找到包含文本的单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个大而复杂的日程表,我想要一个视图,它将日程表显示为日间网格,另一个视图允许用户按字母顺序列表查找扬声器。我已经在这里发布了一个简化的例子:





在字母表中,日期和时间应由使用MATCH的函数填充。作为一个例子,我手动键入了我想要发生的琼斯。



我不能让MATCH()正确地在时间表中找到说话者的名字。没有隐藏的字符:注意在单元格D15中,Excel正确识别出G2和C7是相同的。



如果我将各种代码放在H2中,会发生什么:




  • =匹配(G2,$ A $ 1:$ D $ 9)导致#N / A

  • = MATCH(G2,$ C $ 2:$ C $ 9)
  • = MATCH(G2,$ B $ 7:$ D $ 7)导致2(正确!)

  • = MATCH(G2,$ A $ 7:$ D $ 7)导致#N / A



我想要的是= MATCH(G2,$ A $ 1:$ D $ 9)转换为H2,然后将单元格填充到H25,并且Excel将显示相邻名称出现的一天的列号,然后使用INDIRECT或某些东西将该数字转换为星期几。



由于数据类型不同,搜索阵列中的列A可能会导致问题。作为一个实验,我将第一列列入TEXT,在这种情况下= MATCH(G2,$ A $ 7:$ D $ 7)不正确地返回1!



甚至所以,我不明白为什么$ B $ 7:$ D $ 7工作,但$ C $ 2:$ C $ 9或$ B $ 7:$ D $ 8将。



任何解决方法或者替代策略将非常感谢,谢谢。

解决方案

为此,您需要添加一些其他逻辑来找到正确的列和行。这个AGGREGATE()函数做了这个工作。



日常使用:

  = INDEX($ A $ 1:$ D $ 1,积分(15,6,COLUMN($ A $ 2:$ D $ 9)/(($ A $ 2:$ D = 9 = G2)),1))

对于小时:

  = INDEX($ A $ 1:$ A $ 9,累积(15,6,ROW($ B $ 1:$ D $ 9)/(($ B $ 1:$ D = 9 = G2)),1))



在Excel 2010中引入了AGGREGATE()函数。






对于其他版本: strong>



2010年之前,他们将需要是数组公式:



日:

  = INDEX($ A $ 1:$ D $ 1,MIN $ 2:$ D $ 9 = G2,COLUMN($ A $ 2:$ D $ 9)))

小时:

  = INDEX($ A $ 1:$ A $ 9,MIN(IF($ B $ 1:$ D $ 9 = G2 ,ROW($ B $ 1:$ D $ 9)))

作为数组公式,当退出编辑模式时,必须使用Ctrl-Shift-Enter确认。完成后,Excel会自动将{}围绕公式表示数组公式。



最新的Office 360​​或在线:



日:

  = INDEX($ A $ 1 :$ D $ 1,MINIFS(COLUMN($ A $ 2:$ D $ 9),$ A $ 2:$ D $ 9,G2))

小时:

  = INDEX($ A $ 1:$ A $ 9,MINIFS(ROW B $ 1:$ D $ 9),$ B $ 1:$ D $ 9,G2))




$ b关于MATCH在这种情况下无法工作的原因:



MATCH()仅适用于单个行或列,而不适用于多列/行范围。它设置为返回等于找到的订单位置的数字,因此必须是一维数组。


I am creating a large and complicated schedule, and I want one view which shows the schedule as a day-time grid, and another which allows one to look up a speaker by name from an alphabetical list. I have posted a simplified example here:

In the alphabetical list, the day and time should be populated by a function using MATCH. Just as an example, I manually typed what I would like to have happen for Jones.

I cannot get MATCH() to locate the speaker's name in the timetable correctly. There are no hidden characters: notice that in cell D15, Excel correctly recognizes that G2 and C7 are identical.

Here is what happens if I put various code in H2:

  • =MATCH(G2,$A$1:$D$9) results in #N/A
  • =MATCH(G2,$C$2:$C$9) results in #N/A
  • =MATCH(G2,$B$7:$D$7) results in 2 (correctly!)
  • =MATCH(G2,$A$7:$D$7) results in #N/A

What I would like is to put =MATCH(G2,$A$1:$D$9) into H2 and then fill cells down to H25, and have Excel indicate the column number of the day in which the adjacent name appears, then use INDIRECT or something to convert this number into the day of the week.

It may be that including column A in the search array causes problems because of the different data types. As an experiment, I made the first column into TEXT, and in this case =MATCH(G2,$A$7:$D$7) incorrectly returns 1!

And even so, I cannot understand why $B$7:$D$7 works but neither $C$2:$C$9 nor $B$7:$D$8 will.

Any workarounds or alternative strategies would be greatly appreciated, thanks.

解决方案

To do this you need to add in some other logic to find the correct column and row. This AGGREGATE() Function does the job.

For Day use:

=INDEX($A$1:$D$1,AGGREGATE(15,6,COLUMN($A$2:$D$9)/(($A$2:$D$9=G2)),1))

For Hour:

=INDEX($A$1:$A$9,AGGREGATE(15,6,ROW($B$1:$D$9)/(($B$1:$D$9=G2)),1))

The AGGREGATE() Function was introduced in Excel 2010.


For other Versions:

Pre 2010, they will need to be Array Formulas:

Day:

=INDEX($A$1:$D$1,MIN(IF($A$2:$D$9=G2,COLUMN($A$2:$D$9))))

Hour:

=INDEX($A$1:$A$9,MIN(IF($B$1:$D$9=G2,ROW($B$1:$D$9))))

Being an Array Formula it must be confirmed with Ctrl-Shift-Enter when exiting Edit mode. When done correctly Excel will automatically put {} around the formula to denote an array formula.

Newest Office 360 or online:

Day:

=INDEX($A$1:$D$1,MINIFS(COLUMN($A$2:$D$9),$A$2:$D$9,G2))

Hour:

=INDEX($A$1:$A$9,MINIFS(ROW($B$1:$D$9),$B$1:$D$9,G2))


As to the reason MATCH will not work in this case:

MATCH() only works with a single row or column and not a multiple column/row range. It is set up to return a number equal to the order place found and therefore must be a 1 dimensional array.

这篇关于MS Excel:“MATCH()”如果查找数组太大,则不会找到包含文本的单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆