[英]How to find max and min in an alphanumeric data array in Excel?
I have the following kind of data 我有以下几种数据
A1 B1 C1 D1
II Cm2 447 I Phy Hn 60 II Cm2 457 I Phy Hn 70
II Cm2 448 I Phy Hn 61 II Cm2 458 I Phy Hn 71
II Cm2 449 I Phy Hn 62 II Cm2 459 I Phy Hn 72
II Cm2 450 I Phy Hn 63 II Cm2 460 I Phy Hn 73
II Cm2 451 I Phy Hn 64 II Cm2 461 I Phy Hn 74
II Cm2 452 I Phy Hn 65 II Cm2 462 I Phy Hn 75
II Cm2 453 I Phy Hn 66 II Cm2 463 I PHY ml 76
II Cm2 454 I Phy Hn 67 II Cm2 464 I PHY ml 77
II Cm2 455 I Phy Hn 68 II Cm2 465 I PHY ml 78
II Cm2 456 I Phy Hn 69 II Cm2 466 I PHY ml 79
Need to find Minimum and Maximum corresponding to ' II Cm2 ', ' I Phy Hn ' and ' I PHY ml ' 需要找到对应于“ II Cm2 ”,“ I Phy Hn ”和“ I PHY ml ”的最小值和最大值
Please Help. 请帮忙。
The solution I am looking at 我正在寻找的解决方案
Grid Min Max
II Cm2 447 466
I Phy Hn 60 75
I Phy ml 76 79
EDIT: I have tried several options available over internet, using VLOOKUP, RIGHT, INDEX,... But none gives me intended answer. 编辑:我已经尝试使用Internet上的几种选项,使用VLOOKUP,RIGHT,INDEX,...,但是没有一个给我想要的答案。 I would prefer a solution without using helper columns.
我希望不使用辅助列的解决方案。 If need to use helper columns, please suggest a solution without requiring modification of my cols A:D.
如果需要使用辅助列,请提出解决方案,而无需修改我的cols A:D。
For Min I have a solution MIN(VLOOKUP("II Cm2",$AE$4:$AF$171,2,0), but it requires a helper column of extracted numbers from a single column of my original data. 对于Min,我有一个解决方案MIN(VLOOKUP(“ II Cm2”,$ AE $ 4:$ AF $ 171,2,0),但它需要一个从原始数据的单个列中提取数字的助手列。
Solutions using macro/script also welcome. 也欢迎使用宏/脚本的解决方案。
If you need to extract only Min/Max number from range, please use this formula in cell G2
and drag it to the bottom of values you entered in range F2:F5
. 如果您只需要从范围中提取最小/最大数,请在单元格
G2
使用此公式,并将其拖到您在范围F2:F5
输入的值的底部。 =MIN(IF(ISNUMBER(SUBSTITUTE($A$2:$D$500,$F2,"")+0),SUBSTITUTE($A$2:$D$500,$F2,"")+0))
you must enter it using CTRL+SHIFT+ENTER
combination since it it array formula. =MIN(IF(ISNUMBER(SUBSTITUTE($A$2:$D$500,$F2,"")+0),SUBSTITUTE($A$2:$D$500,$F2,"")+0))
您必须输入它使用CTRL+SHIFT+ENTER
组合,因为它可以数组公式。 For Max just replace Min in formula. 对于Max,只需在公式中替换Min。
You can read about how to create a formula that takes a range of cells as a parameter here . 您可以在此处阅读有关如何创建将一系列单元格作为参数的公式的信息 。
This is one way to return just the numbers from a string. 这是仅返回字符串中数字的一种方法。
Here is a function that looks for one string within another, backwards. 这是一个在另一个字符串中向后寻找一个字符串的函数 。
This tells you about changing a string into a number. 这告诉您有关将字符串更改为数字的信息。
Below is one way that you could put them together to find your 'max' value: 以下是将它们组合在一起以找到“最大”价值的一种方法:
Function MaxValueOfRange(rng As Range) As Integer
Dim c As Range, strIn As String, intRet As Integer
For Each c In rng 'loop through each cell in range
strIn = Right(c, Len(c) - InStrRev(c, " ")) 'get everything after the last 'space'
Next
If Val(strRet) > intRet Then intRet = Val(strRet) 'convert it to number and keep the biggest one
MaxValueOfRange = intRet 'return the biggest number
End Function
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.