范围内的索引匹配功能

时间:2019-04-19 12:25:35

标签: excel vba

起初它看起来很简单,但是我一直试图寻找一种解决方法。想法是找到匹配C1并落入给定范围C2的C3。基本上B 40 shuold收益-0.15。有任何建议吗?

图片:

Example

我尝试了索引匹配功能,但在没有范围的情况下工作正常。每次C2值都是恒定的,只有C3改变。

1 个答案:

答案 0 :(得分:0)

这是我逐步解决的方法

基于此数据:

enter image description here

1)从混合单元格中获得字母

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(F4,0,""""),1,""""),2,""""),3,""""),4,""""),5,""""),6,""""),7,""""),8,""""),9,"""")

2)从混合单元格中获取数字:

=VALUE(MID(F4,FIND(F6,F4)+1,LEN(F4)))

3)寻找第一个字母:

=MATCH(F6,$A$4:$A$13,0)

4)算盘字母:

=COUNTIF($A$4:$A$13,F6)

5)引用字母范围(我将其包裹在屏幕快照中并使用Sum()进行测试):

=OFFSET($A$4,F8-1,1,F9,2)

6)返回值:

=VLOOKUP(F7,OFFSET($A$4,F8-1,1,F9,2),2,TRUE)

一次全部

=VLOOKUP(VALUE(MID(F4,FIND(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(F4,0,""),1,""),2,""),3,""),4,""),5,""),6,""),7,""),8,""),9,""),F4)+1,LEN(F4))),OFFSET($A$4,MATCH(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(F4,0,""),1,""),2,""),3,""),4,""),5,""),6,""),7,""),8,""),9,""),$A$4:$A$13,0)-1,1,COUNTIF($A$4:$A$13,SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(F4,0,""),1,""),2,""),3,""),4,""),5,""),6,""),7,""),8,""),9,"")),2),2,TRUE)