vba 在一个单元格中插入一系列数字
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21855196/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Insert a range of numbers in one cell
提问by user2976978
I have a table in Excel which looks like this:
我在 Excel 中有一个表格,如下所示:
A B C
Row 1: 2100-2200 2200-2300 2300-2400
I'm using a VLOOKUP formula. I want this formula to find a number e.g. 2152 in the table above.
我正在使用 VLOOKUP 公式。我希望这个公式在上表中找到一个数字,例如 2152。
Cell A1 is supposed to contain numbers from 2100 to 2200.
单元格 A1 应该包含从 2100 到 2200 的数字。
Is this possible to do in Excel?
这可以在 Excel 中完成吗?
回答by CRondao
I dont know exactly what you want to return, this array formula will return the correct interval in A1:C1:
我不知道你到底想返回什么,这个数组公式将在 A1:C1 中返回正确的间隔:
=INDEX($A:$C;MATCH(1;(E1>=VALUE(LEFT($A:$C;4)))*(E1<=VALUE(RIGHT($A:$C;4)));0))
Numeric value your looking for in E1
您在 E1 中寻找的数值
Dont forget to Ctrl Shift Enter to enter the formula...
不要忘记 Ctrl Shift Enter 输入公式...
回答by Peter Albert
Instead of providing the ranges, you need to provide only the lower bound. I.e. try this data:
您只需提供下限,而不是提供范围。即尝试此数据:
A B C
Row 1: 2100 2200 2300
Because it is a horizontal setup, you need to use HLOOKUP (VLOOKUP will check the cells in the first column of a table, HLOOKUP the cells in the first row) - and you need to leave the fourth parameter of HLOOKUP/VLOOKUP blank (or set it to TRUE
which is the same as leaving it blank). E.g. if you number 2152
is in cell A2, use this formula:
因为是横向设置,所以需要使用HLOOKUP(VLOOKUP会检查表格第一列的单元格,HLOOKUP会检查第一行的单元格)——并且需要将HLOOKUP/VLOOKUP的第四个参数留空(或者将其设置TRUE
为与将其留空相同)。例如,如果您的数字2152
在单元格 A2 中,请使用以下公式:
=HLOOKUP(A2,$A:$C,1)
and you'll get 2100
.
你会得到2100
.
If you want to have the full range returned, you should use the MATCH
function instead:
如果要返回完整范围,则应改用该MATCH
函数:
=INDEX($A:$C,MATCH(A2,$A:$C))&"-"&INDEX($A:$C,MATCH(A2,$A:$C)+1)
This will return 2100-2200
这将返回 2100-2200
回答by Harrison Kk
use lower range of your numbers
使用较低范围的数字
A B C D
Lower range 2100 2200 2300 2400
Ranking 1 2 3 4
You want to find a number or ranking corresponding to say 2350
你想找到一个数字或排名对应的说 2350
Formula: = HLOOKUP(2350,range (range of your values),2,TRUE)
your range includes 2100 -2400 plus 1-4.
您的范围包括 2100 -2400 加上 1-4。
the value 2 in the formula indicates the row that you want result returned from - in this case you want ranking - where 2350 will return a 4; change this number to 1 to return exact value.
公式中的值 2 表示您希望从中返回结果的行 - 在这种情况下您想要排名 - 其中 2350 将返回 4;将此数字更改为 1 以返回精确值。
sample formula:
示例公式:
= HLOOKUP(O65,J74:N75,2,TRUE)